Skip to content

Commit 47d7dc3

Browse files
committed
Update README
1 parent a276a7c commit 47d7dc3

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,19 +92,26 @@ The following two code samples will be considered to be equivalent:
9292

9393
* **compareAttributesAsJSON: [ Array ]**
9494

95-
Sets what kind of respective attributes' content will be compared as JSON objects, but not as strings (default: `[]`).
95+
Sets what kind of respective attributes' content will be compared as JSON objects, but not as strings (default: `[]`).<br>
96+
In cases when the value of the attribute is an invalid JSON or can not be wrapped into a function, it will be compared as `undefined`.
9697

9798
**Example**: `[{ name: 'data', isFunction: false }, { name: 'onclick', isFunction: true }]`<br>
9899
The following two code samples will be considered to be equivalent:
99100

100101
```html
101102
<div data='{"bla":{"first":"ololo","second":"trololo"}}'></div>
102103
<span onclick='return {"aaa":"bbb","bbb":"aaa"}'></span>
104+
105+
<button data='REALLY BAD JSON'></button>
106+
<button onclick='REALLY BAD FUNCTION'></button>
103107
```
104108

105109
```html
106110
<div data='{"bla":{"second":"trololo","first":"ololo"}}'></div>
107111
<span onclick='return {"bbb":"aaa","aaa":"bbb"}'></span>
112+
113+
<button data='undefined'></button>
114+
<button onclick='undefined'></button>
108115
```
109116

110117
**REMARK!**<br>

README.ru.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,19 +92,26 @@ var HtmlDiffer = require('html-differ').HtmlDiffer,
9292

9393
* **compareAttributesAsJSON: [ Array ]**
9494

95-
Устанавливает, значения каких атрибутов следует сравнивать как JSON-объекты, а не как строки (по умолчанию: `[]`).
95+
Устанавливает, значения каких атрибутов следует сравнивать как JSON-объекты, а не как строки (по умолчанию: `[]`).<br>
96+
В тех случаях, когда в качестве значения атрибута выступает некорректный JSON или это значение нельзя обернуть в функцию, то оно будет сравниваться как `undefined`.
9697

9798
**Пример**: `[{ name: 'data', isFunction: false }, { name: 'onclick', isFunction: true }]`<br>
9899
Следующие два HTML будут считаться эквивалентными:
99100

100101
```html
101102
<div data='{"bla":{"first":"ololo","second":"trololo"}}'></div>
102103
<span onclick='return {"aaa":"bbb","bbb":"aaa"}'></span>
104+
105+
<button data='REALLY BAD JSON'></button>
106+
<button onclick='REALLY BAD FUNCTION'></button>
103107
```
104108

105109
```html
106110
<div data='{"bla":{"second":"trololo","first":"ololo"}}'></div>
107111
<span onclick='return {"bbb":"aaa","aaa":"bbb"}'></span>
112+
113+
<button data='undefined'></button>
114+
<button onclick='undefined'></button>
108115
```
109116

110117
**ПРИМЕЧАНИЕ!**<br>

0 commit comments

Comments
 (0)