You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -31,7 +31,7 @@ Then create an instance of diffDOM within the javascript code:
31
31
dd =newdiffDOM();
32
32
```
33
33
34
-
Now you can create a diff to get from dom elementA to dom elementB like this:
34
+
Now you can create a diff to get from dom `elementA` to dom `elementB` like this:
35
35
```js
36
36
diff =dd.diff(elementA, elementB);
37
37
```
@@ -40,7 +40,7 @@ You can now apply this diff like this:
40
40
```js
41
41
dd.apply(elementA, diff);
42
42
```
43
-
Now elementA will have been changed to be structurally equal to elementB.
43
+
Now `elementA` will have been changed to be structurally equal to `elementB`.
44
44
45
45
### Advanced uses
46
46
@@ -54,7 +54,7 @@ Now elementA will be what it was like before applying the diff.
54
54
55
55
#### Remote changes
56
56
57
-
If you need to move diffs from one machine to another one, you will likely want to send the diffs through a websocket connection or as part of a form submit. In both cases you need to convert the diff to a json string.
57
+
If you need to move diffs from one machine to another one, you will likely want to send the diffs through a websocket connection or as part of a form submit. In both cases you need to convert the diff to a json `string`.
58
58
59
59
To convert a diff to a json string which you can send over the network, do:
60
60
```js
@@ -68,7 +68,7 @@ diff = JSON.parse(diffJson);
68
68
69
69
#### Error handling when patching/applying
70
70
71
-
Sometimes one may try to patch an elment without knowing whether the patch actually will apply cleanly. This should not be a problem. If diffDOM determines that a patch cannot be executed, it will simple return false. Else it will return true:
71
+
Sometimes one may try to patch an elment without knowing whether the patch actually will apply cleanly. This should not be a problem. If diffDOM determines that a patch cannot be executed, it will simple return `false`. Else it will return `true`:
72
72
```js
73
73
result =dd.apply(element, diff);
74
74
@@ -80,7 +80,7 @@ if (result) {
80
80
```
81
81
#### Advanced merging of text node changes
82
82
83
-
diffDOM does not include merging for changes to text nodes. However, it includes hooks so that you can add more advanced handling. Simple overwrite the textDiff function of the diffDOM instance. The functions TEXTDIFF and TEXTPATCH need to be defined in the code:
83
+
diffDOM does not include merging for changes to text nodes. However, it includes hooks so that you can add more advanced handling. Simple overwrite the `textDiff` function of the `diffDOM` instance. The functions TEXTDIFF and TEXTPATCH need to be defined in the code:
Additionally, the _pre_ hooks allow you to shortcircuit the standard behaviour of the diff by returning 'true' from this callback. This will cause the diffApply functions to return prematurely, skipping their standard behaviour.
121
+
Additionally, the _pre_ hooks allow you to shortcircuit the standard behaviour of the diff by returning `true` from this callback. This will cause the `diffApply` functions to return prematurely, skipping their standard behaviour.
0 commit comments