async-debug 0.1.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/async/debug/application.rb +21 -0
- data/lib/async/debug/reactor_view.rb +7 -24
- data/lib/async/debug/version.rb +3 -20
- data/lib/async/debug.rb +15 -71
- data/license.md +21 -0
- data/readme.md +27 -0
- data.tar.gz.sig +0 -0
- metadata +45 -182
- metadata.gz.sig +0 -0
- data/pages/_heading.xnode +0 -2
- data/pages/_page.xnode +0 -42
- data/pages/controller.rb +0 -19
- data/pages/errors/exception.xnode +0 -5
- data/pages/errors/file-not-found.xnode +0 -5
- data/pages/index.xnode +0 -3
- data/pages/links.yaml +0 -4
- data/public/_components/@socketry/live/live.js +0 -157
- data/public/_components/@socketry/live/live.min.js +0 -1
- data/public/_components/jquery/jquery.js +0 -10872
- data/public/_components/jquery/jquery.min.js +0 -2
- data/public/_components/jquery/jquery.min.map +0 -1
- data/public/_components/jquery/jquery.slim.js +0 -8777
- data/public/_components/jquery/jquery.slim.min.js +0 -2
- data/public/_components/jquery/jquery.slim.min.map +0 -1
- data/public/_components/jquery-syntax/base/jquery.syntax.brush.apache.css +0 -12
- data/public/_components/jquery-syntax/base/jquery.syntax.brush.applescript.css +0 -5
- data/public/_components/jquery-syntax/base/jquery.syntax.brush.assembly.css +0 -8
- data/public/_components/jquery-syntax/base/jquery.syntax.brush.bash-script.css +0 -4
- data/public/_components/jquery-syntax/base/jquery.syntax.brush.bash.css +0 -2
- data/public/_components/jquery-syntax/base/jquery.syntax.brush.clang.css +0 -6
- data/public/_components/jquery-syntax/base/jquery.syntax.brush.css.css +0 -14
- data/public/_components/jquery-syntax/base/jquery.syntax.brush.diff.css +0 -16
- data/public/_components/jquery-syntax/base/jquery.syntax.brush.html.css +0 -5
- data/public/_components/jquery-syntax/base/jquery.syntax.brush.ocaml.css +0 -3
- data/public/_components/jquery-syntax/base/jquery.syntax.brush.protobuf.css +0 -2
- data/public/_components/jquery-syntax/base/jquery.syntax.brush.python.css +0 -6
- data/public/_components/jquery-syntax/base/jquery.syntax.brush.ruby.css +0 -2
- data/public/_components/jquery-syntax/base/jquery.syntax.brush.xml.css +0 -35
- data/public/_components/jquery-syntax/base/jquery.syntax.core.css +0 -58
- data/public/_components/jquery-syntax/base/jquery.syntax.editor.css +0 -6
- data/public/_components/jquery-syntax/base/theme.js +0 -1
- data/public/_components/jquery-syntax/bright/jquery.syntax.core.css +0 -27
- data/public/_components/jquery-syntax/bright/theme.js +0 -1
- data/public/_components/jquery-syntax/jquery.syntax.brush.apache.js +0 -3
- data/public/_components/jquery-syntax/jquery.syntax.brush.applescript.js +0 -5
- data/public/_components/jquery-syntax/jquery.syntax.brush.assembly.js +0 -3
- data/public/_components/jquery-syntax/jquery.syntax.brush.bash-script.js +0 -4
- data/public/_components/jquery-syntax/jquery.syntax.brush.bash.js +0 -2
- data/public/_components/jquery-syntax/jquery.syntax.brush.basic.js +0 -5
- data/public/_components/jquery-syntax/jquery.syntax.brush.clang.js +0 -5
- data/public/_components/jquery-syntax/jquery.syntax.brush.csharp.js +0 -4
- data/public/_components/jquery-syntax/jquery.syntax.brush.css.js +0 -5
- data/public/_components/jquery-syntax/jquery.syntax.brush.diff.js +0 -2
- data/public/_components/jquery-syntax/jquery.syntax.brush.go.js +0 -3
- data/public/_components/jquery-syntax/jquery.syntax.brush.haskell.js +0 -3
- data/public/_components/jquery-syntax/jquery.syntax.brush.html.js +0 -4
- data/public/_components/jquery-syntax/jquery.syntax.brush.io.js +0 -3
- data/public/_components/jquery-syntax/jquery.syntax.brush.java.js +0 -4
- data/public/_components/jquery-syntax/jquery.syntax.brush.javascript.js +0 -3
- data/public/_components/jquery-syntax/jquery.syntax.brush.kai.js +0 -2
- data/public/_components/jquery-syntax/jquery.syntax.brush.lisp.js +0 -2
- data/public/_components/jquery-syntax/jquery.syntax.brush.lua.js +0 -3
- data/public/_components/jquery-syntax/jquery.syntax.brush.nginx.js +0 -2
- data/public/_components/jquery-syntax/jquery.syntax.brush.ocaml.js +0 -4
- data/public/_components/jquery-syntax/jquery.syntax.brush.ooc.js +0 -4
- data/public/_components/jquery-syntax/jquery.syntax.brush.pascal.js +0 -4
- data/public/_components/jquery-syntax/jquery.syntax.brush.perl5.js +0 -3
- data/public/_components/jquery-syntax/jquery.syntax.brush.php-script.js +0 -4
- data/public/_components/jquery-syntax/jquery.syntax.brush.php.js +0 -2
- data/public/_components/jquery-syntax/jquery.syntax.brush.plain.js +0 -2
- data/public/_components/jquery-syntax/jquery.syntax.brush.protobuf.js +0 -3
- data/public/_components/jquery-syntax/jquery.syntax.brush.python.js +0 -5
- data/public/_components/jquery-syntax/jquery.syntax.brush.ruby.js +0 -5
- data/public/_components/jquery-syntax/jquery.syntax.brush.scala.js +0 -4
- data/public/_components/jquery-syntax/jquery.syntax.brush.smalltalk.js +0 -2
- data/public/_components/jquery-syntax/jquery.syntax.brush.sql.js +0 -4
- data/public/_components/jquery-syntax/jquery.syntax.brush.super-collider.js +0 -3
- data/public/_components/jquery-syntax/jquery.syntax.brush.swift.js +0 -3
- data/public/_components/jquery-syntax/jquery.syntax.brush.trenni.js +0 -2
- data/public/_components/jquery-syntax/jquery.syntax.brush.xml.js +0 -4
- data/public/_components/jquery-syntax/jquery.syntax.brush.yaml.js +0 -2
- data/public/_components/jquery-syntax/jquery.syntax.cache.js +0 -7
- data/public/_components/jquery-syntax/jquery.syntax.core.js +0 -34
- data/public/_components/jquery-syntax/jquery.syntax.editor.js +0 -11
- data/public/_components/jquery-syntax/jquery.syntax.js +0 -8
- data/public/_components/jquery-syntax/jquery.syntax.min.js +0 -13
- data/public/_components/jquery-syntax/paper/jquery.syntax.core.css +0 -31
- data/public/_components/jquery-syntax/paper/theme.js +0 -1
- data/public/_components/morphdom/morphdom-esm.js +0 -755
- data/public/_components/morphdom/morphdom-factory.js +0 -691
- data/public/_components/morphdom/morphdom-umd.js +0 -763
- data/public/_components/morphdom/morphdom-umd.min.js +0 -1
- data/public/_components/morphdom/morphdom.js +0 -757
- data/public/_static/icon.png +0 -0
- data/public/_static/links.js +0 -21
- /data/public/_static/{site.css → index.css} +0 -0
@@ -1,755 +0,0 @@
|
|
1
|
-
var DOCUMENT_FRAGMENT_NODE = 11;
|
2
|
-
|
3
|
-
function morphAttrs(fromNode, toNode) {
|
4
|
-
var toNodeAttrs = toNode.attributes;
|
5
|
-
var attr;
|
6
|
-
var attrName;
|
7
|
-
var attrNamespaceURI;
|
8
|
-
var attrValue;
|
9
|
-
var fromValue;
|
10
|
-
|
11
|
-
// document-fragments dont have attributes so lets not do anything
|
12
|
-
if (toNode.nodeType === DOCUMENT_FRAGMENT_NODE || fromNode.nodeType === DOCUMENT_FRAGMENT_NODE) {
|
13
|
-
return;
|
14
|
-
}
|
15
|
-
|
16
|
-
// update attributes on original DOM element
|
17
|
-
for (var i = toNodeAttrs.length - 1; i >= 0; i--) {
|
18
|
-
attr = toNodeAttrs[i];
|
19
|
-
attrName = attr.name;
|
20
|
-
attrNamespaceURI = attr.namespaceURI;
|
21
|
-
attrValue = attr.value;
|
22
|
-
|
23
|
-
if (attrNamespaceURI) {
|
24
|
-
attrName = attr.localName || attrName;
|
25
|
-
fromValue = fromNode.getAttributeNS(attrNamespaceURI, attrName);
|
26
|
-
|
27
|
-
if (fromValue !== attrValue) {
|
28
|
-
if (attr.prefix === 'xmlns'){
|
29
|
-
attrName = attr.name; // It's not allowed to set an attribute with the XMLNS namespace without specifying the `xmlns` prefix
|
30
|
-
}
|
31
|
-
fromNode.setAttributeNS(attrNamespaceURI, attrName, attrValue);
|
32
|
-
}
|
33
|
-
} else {
|
34
|
-
fromValue = fromNode.getAttribute(attrName);
|
35
|
-
|
36
|
-
if (fromValue !== attrValue) {
|
37
|
-
fromNode.setAttribute(attrName, attrValue);
|
38
|
-
}
|
39
|
-
}
|
40
|
-
}
|
41
|
-
|
42
|
-
// Remove any extra attributes found on the original DOM element that
|
43
|
-
// weren't found on the target element.
|
44
|
-
var fromNodeAttrs = fromNode.attributes;
|
45
|
-
|
46
|
-
for (var d = fromNodeAttrs.length - 1; d >= 0; d--) {
|
47
|
-
attr = fromNodeAttrs[d];
|
48
|
-
attrName = attr.name;
|
49
|
-
attrNamespaceURI = attr.namespaceURI;
|
50
|
-
|
51
|
-
if (attrNamespaceURI) {
|
52
|
-
attrName = attr.localName || attrName;
|
53
|
-
|
54
|
-
if (!toNode.hasAttributeNS(attrNamespaceURI, attrName)) {
|
55
|
-
fromNode.removeAttributeNS(attrNamespaceURI, attrName);
|
56
|
-
}
|
57
|
-
} else {
|
58
|
-
if (!toNode.hasAttribute(attrName)) {
|
59
|
-
fromNode.removeAttribute(attrName);
|
60
|
-
}
|
61
|
-
}
|
62
|
-
}
|
63
|
-
}
|
64
|
-
|
65
|
-
var range; // Create a range object for efficently rendering strings to elements.
|
66
|
-
var NS_XHTML = 'http://www.w3.org/1999/xhtml';
|
67
|
-
|
68
|
-
var doc = typeof document === 'undefined' ? undefined : document;
|
69
|
-
var HAS_TEMPLATE_SUPPORT = !!doc && 'content' in doc.createElement('template');
|
70
|
-
var HAS_RANGE_SUPPORT = !!doc && doc.createRange && 'createContextualFragment' in doc.createRange();
|
71
|
-
|
72
|
-
function createFragmentFromTemplate(str) {
|
73
|
-
var template = doc.createElement('template');
|
74
|
-
template.innerHTML = str;
|
75
|
-
return template.content.childNodes[0];
|
76
|
-
}
|
77
|
-
|
78
|
-
function createFragmentFromRange(str) {
|
79
|
-
if (!range) {
|
80
|
-
range = doc.createRange();
|
81
|
-
range.selectNode(doc.body);
|
82
|
-
}
|
83
|
-
|
84
|
-
var fragment = range.createContextualFragment(str);
|
85
|
-
return fragment.childNodes[0];
|
86
|
-
}
|
87
|
-
|
88
|
-
function createFragmentFromWrap(str) {
|
89
|
-
var fragment = doc.createElement('body');
|
90
|
-
fragment.innerHTML = str;
|
91
|
-
return fragment.childNodes[0];
|
92
|
-
}
|
93
|
-
|
94
|
-
/**
|
95
|
-
* This is about the same
|
96
|
-
* var html = new DOMParser().parseFromString(str, 'text/html');
|
97
|
-
* return html.body.firstChild;
|
98
|
-
*
|
99
|
-
* @method toElement
|
100
|
-
* @param {String} str
|
101
|
-
*/
|
102
|
-
function toElement(str) {
|
103
|
-
str = str.trim();
|
104
|
-
if (HAS_TEMPLATE_SUPPORT) {
|
105
|
-
// avoid restrictions on content for things like `<tr><th>Hi</th></tr>` which
|
106
|
-
// createContextualFragment doesn't support
|
107
|
-
// <template> support not available in IE
|
108
|
-
return createFragmentFromTemplate(str);
|
109
|
-
} else if (HAS_RANGE_SUPPORT) {
|
110
|
-
return createFragmentFromRange(str);
|
111
|
-
}
|
112
|
-
|
113
|
-
return createFragmentFromWrap(str);
|
114
|
-
}
|
115
|
-
|
116
|
-
/**
|
117
|
-
* Returns true if two node's names are the same.
|
118
|
-
*
|
119
|
-
* NOTE: We don't bother checking `namespaceURI` because you will never find two HTML elements with the same
|
120
|
-
* nodeName and different namespace URIs.
|
121
|
-
*
|
122
|
-
* @param {Element} a
|
123
|
-
* @param {Element} b The target element
|
124
|
-
* @return {boolean}
|
125
|
-
*/
|
126
|
-
function compareNodeNames(fromEl, toEl) {
|
127
|
-
var fromNodeName = fromEl.nodeName;
|
128
|
-
var toNodeName = toEl.nodeName;
|
129
|
-
var fromCodeStart, toCodeStart;
|
130
|
-
|
131
|
-
if (fromNodeName === toNodeName) {
|
132
|
-
return true;
|
133
|
-
}
|
134
|
-
|
135
|
-
fromCodeStart = fromNodeName.charCodeAt(0);
|
136
|
-
toCodeStart = toNodeName.charCodeAt(0);
|
137
|
-
|
138
|
-
// If the target element is a virtual DOM node or SVG node then we may
|
139
|
-
// need to normalize the tag name before comparing. Normal HTML elements that are
|
140
|
-
// in the "http://www.w3.org/1999/xhtml"
|
141
|
-
// are converted to upper case
|
142
|
-
if (fromCodeStart <= 90 && toCodeStart >= 97) { // from is upper and to is lower
|
143
|
-
return fromNodeName === toNodeName.toUpperCase();
|
144
|
-
} else if (toCodeStart <= 90 && fromCodeStart >= 97) { // to is upper and from is lower
|
145
|
-
return toNodeName === fromNodeName.toUpperCase();
|
146
|
-
} else {
|
147
|
-
return false;
|
148
|
-
}
|
149
|
-
}
|
150
|
-
|
151
|
-
/**
|
152
|
-
* Create an element, optionally with a known namespace URI.
|
153
|
-
*
|
154
|
-
* @param {string} name the element name, e.g. 'div' or 'svg'
|
155
|
-
* @param {string} [namespaceURI] the element's namespace URI, i.e. the value of
|
156
|
-
* its `xmlns` attribute or its inferred namespace.
|
157
|
-
*
|
158
|
-
* @return {Element}
|
159
|
-
*/
|
160
|
-
function createElementNS(name, namespaceURI) {
|
161
|
-
return !namespaceURI || namespaceURI === NS_XHTML ?
|
162
|
-
doc.createElement(name) :
|
163
|
-
doc.createElementNS(namespaceURI, name);
|
164
|
-
}
|
165
|
-
|
166
|
-
/**
|
167
|
-
* Copies the children of one DOM element to another DOM element
|
168
|
-
*/
|
169
|
-
function moveChildren(fromEl, toEl) {
|
170
|
-
var curChild = fromEl.firstChild;
|
171
|
-
while (curChild) {
|
172
|
-
var nextChild = curChild.nextSibling;
|
173
|
-
toEl.appendChild(curChild);
|
174
|
-
curChild = nextChild;
|
175
|
-
}
|
176
|
-
return toEl;
|
177
|
-
}
|
178
|
-
|
179
|
-
function syncBooleanAttrProp(fromEl, toEl, name) {
|
180
|
-
if (fromEl[name] !== toEl[name]) {
|
181
|
-
fromEl[name] = toEl[name];
|
182
|
-
if (fromEl[name]) {
|
183
|
-
fromEl.setAttribute(name, '');
|
184
|
-
} else {
|
185
|
-
fromEl.removeAttribute(name);
|
186
|
-
}
|
187
|
-
}
|
188
|
-
}
|
189
|
-
|
190
|
-
var specialElHandlers = {
|
191
|
-
OPTION: function(fromEl, toEl) {
|
192
|
-
var parentNode = fromEl.parentNode;
|
193
|
-
if (parentNode) {
|
194
|
-
var parentName = parentNode.nodeName.toUpperCase();
|
195
|
-
if (parentName === 'OPTGROUP') {
|
196
|
-
parentNode = parentNode.parentNode;
|
197
|
-
parentName = parentNode && parentNode.nodeName.toUpperCase();
|
198
|
-
}
|
199
|
-
if (parentName === 'SELECT' && !parentNode.hasAttribute('multiple')) {
|
200
|
-
if (fromEl.hasAttribute('selected') && !toEl.selected) {
|
201
|
-
// Workaround for MS Edge bug where the 'selected' attribute can only be
|
202
|
-
// removed if set to a non-empty value:
|
203
|
-
// https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/12087679/
|
204
|
-
fromEl.setAttribute('selected', 'selected');
|
205
|
-
fromEl.removeAttribute('selected');
|
206
|
-
}
|
207
|
-
// We have to reset select element's selectedIndex to -1, otherwise setting
|
208
|
-
// fromEl.selected using the syncBooleanAttrProp below has no effect.
|
209
|
-
// The correct selectedIndex will be set in the SELECT special handler below.
|
210
|
-
parentNode.selectedIndex = -1;
|
211
|
-
}
|
212
|
-
}
|
213
|
-
syncBooleanAttrProp(fromEl, toEl, 'selected');
|
214
|
-
},
|
215
|
-
/**
|
216
|
-
* The "value" attribute is special for the <input> element since it sets
|
217
|
-
* the initial value. Changing the "value" attribute without changing the
|
218
|
-
* "value" property will have no effect since it is only used to the set the
|
219
|
-
* initial value. Similar for the "checked" attribute, and "disabled".
|
220
|
-
*/
|
221
|
-
INPUT: function(fromEl, toEl) {
|
222
|
-
syncBooleanAttrProp(fromEl, toEl, 'checked');
|
223
|
-
syncBooleanAttrProp(fromEl, toEl, 'disabled');
|
224
|
-
|
225
|
-
if (fromEl.value !== toEl.value) {
|
226
|
-
fromEl.value = toEl.value;
|
227
|
-
}
|
228
|
-
|
229
|
-
if (!toEl.hasAttribute('value')) {
|
230
|
-
fromEl.removeAttribute('value');
|
231
|
-
}
|
232
|
-
},
|
233
|
-
|
234
|
-
TEXTAREA: function(fromEl, toEl) {
|
235
|
-
var newValue = toEl.value;
|
236
|
-
if (fromEl.value !== newValue) {
|
237
|
-
fromEl.value = newValue;
|
238
|
-
}
|
239
|
-
|
240
|
-
var firstChild = fromEl.firstChild;
|
241
|
-
if (firstChild) {
|
242
|
-
// Needed for IE. Apparently IE sets the placeholder as the
|
243
|
-
// node value and vise versa. This ignores an empty update.
|
244
|
-
var oldValue = firstChild.nodeValue;
|
245
|
-
|
246
|
-
if (oldValue == newValue || (!newValue && oldValue == fromEl.placeholder)) {
|
247
|
-
return;
|
248
|
-
}
|
249
|
-
|
250
|
-
firstChild.nodeValue = newValue;
|
251
|
-
}
|
252
|
-
},
|
253
|
-
SELECT: function(fromEl, toEl) {
|
254
|
-
if (!toEl.hasAttribute('multiple')) {
|
255
|
-
var selectedIndex = -1;
|
256
|
-
var i = 0;
|
257
|
-
// We have to loop through children of fromEl, not toEl since nodes can be moved
|
258
|
-
// from toEl to fromEl directly when morphing.
|
259
|
-
// At the time this special handler is invoked, all children have already been morphed
|
260
|
-
// and appended to / removed from fromEl, so using fromEl here is safe and correct.
|
261
|
-
var curChild = fromEl.firstChild;
|
262
|
-
var optgroup;
|
263
|
-
var nodeName;
|
264
|
-
while(curChild) {
|
265
|
-
nodeName = curChild.nodeName && curChild.nodeName.toUpperCase();
|
266
|
-
if (nodeName === 'OPTGROUP') {
|
267
|
-
optgroup = curChild;
|
268
|
-
curChild = optgroup.firstChild;
|
269
|
-
} else {
|
270
|
-
if (nodeName === 'OPTION') {
|
271
|
-
if (curChild.hasAttribute('selected')) {
|
272
|
-
selectedIndex = i;
|
273
|
-
break;
|
274
|
-
}
|
275
|
-
i++;
|
276
|
-
}
|
277
|
-
curChild = curChild.nextSibling;
|
278
|
-
if (!curChild && optgroup) {
|
279
|
-
curChild = optgroup.nextSibling;
|
280
|
-
optgroup = null;
|
281
|
-
}
|
282
|
-
}
|
283
|
-
}
|
284
|
-
|
285
|
-
fromEl.selectedIndex = selectedIndex;
|
286
|
-
}
|
287
|
-
}
|
288
|
-
};
|
289
|
-
|
290
|
-
var ELEMENT_NODE = 1;
|
291
|
-
var DOCUMENT_FRAGMENT_NODE$1 = 11;
|
292
|
-
var TEXT_NODE = 3;
|
293
|
-
var COMMENT_NODE = 8;
|
294
|
-
|
295
|
-
function noop() {}
|
296
|
-
|
297
|
-
function defaultGetNodeKey(node) {
|
298
|
-
if (node) {
|
299
|
-
return (node.getAttribute && node.getAttribute('id')) || node.id;
|
300
|
-
}
|
301
|
-
}
|
302
|
-
|
303
|
-
function morphdomFactory(morphAttrs) {
|
304
|
-
|
305
|
-
return function morphdom(fromNode, toNode, options) {
|
306
|
-
if (!options) {
|
307
|
-
options = {};
|
308
|
-
}
|
309
|
-
|
310
|
-
if (typeof toNode === 'string') {
|
311
|
-
if (fromNode.nodeName === '#document' || fromNode.nodeName === 'HTML' || fromNode.nodeName === 'BODY') {
|
312
|
-
var toNodeHtml = toNode;
|
313
|
-
toNode = doc.createElement('html');
|
314
|
-
toNode.innerHTML = toNodeHtml;
|
315
|
-
} else {
|
316
|
-
toNode = toElement(toNode);
|
317
|
-
}
|
318
|
-
}
|
319
|
-
|
320
|
-
var getNodeKey = options.getNodeKey || defaultGetNodeKey;
|
321
|
-
var onBeforeNodeAdded = options.onBeforeNodeAdded || noop;
|
322
|
-
var onNodeAdded = options.onNodeAdded || noop;
|
323
|
-
var onBeforeElUpdated = options.onBeforeElUpdated || noop;
|
324
|
-
var onElUpdated = options.onElUpdated || noop;
|
325
|
-
var onBeforeNodeDiscarded = options.onBeforeNodeDiscarded || noop;
|
326
|
-
var onNodeDiscarded = options.onNodeDiscarded || noop;
|
327
|
-
var onBeforeElChildrenUpdated = options.onBeforeElChildrenUpdated || noop;
|
328
|
-
var childrenOnly = options.childrenOnly === true;
|
329
|
-
|
330
|
-
// This object is used as a lookup to quickly find all keyed elements in the original DOM tree.
|
331
|
-
var fromNodesLookup = Object.create(null);
|
332
|
-
var keyedRemovalList = [];
|
333
|
-
|
334
|
-
function addKeyedRemoval(key) {
|
335
|
-
keyedRemovalList.push(key);
|
336
|
-
}
|
337
|
-
|
338
|
-
function walkDiscardedChildNodes(node, skipKeyedNodes) {
|
339
|
-
if (node.nodeType === ELEMENT_NODE) {
|
340
|
-
var curChild = node.firstChild;
|
341
|
-
while (curChild) {
|
342
|
-
|
343
|
-
var key = undefined;
|
344
|
-
|
345
|
-
if (skipKeyedNodes && (key = getNodeKey(curChild))) {
|
346
|
-
// If we are skipping keyed nodes then we add the key
|
347
|
-
// to a list so that it can be handled at the very end.
|
348
|
-
addKeyedRemoval(key);
|
349
|
-
} else {
|
350
|
-
// Only report the node as discarded if it is not keyed. We do this because
|
351
|
-
// at the end we loop through all keyed elements that were unmatched
|
352
|
-
// and then discard them in one final pass.
|
353
|
-
onNodeDiscarded(curChild);
|
354
|
-
if (curChild.firstChild) {
|
355
|
-
walkDiscardedChildNodes(curChild, skipKeyedNodes);
|
356
|
-
}
|
357
|
-
}
|
358
|
-
|
359
|
-
curChild = curChild.nextSibling;
|
360
|
-
}
|
361
|
-
}
|
362
|
-
}
|
363
|
-
|
364
|
-
/**
|
365
|
-
* Removes a DOM node out of the original DOM
|
366
|
-
*
|
367
|
-
* @param {Node} node The node to remove
|
368
|
-
* @param {Node} parentNode The nodes parent
|
369
|
-
* @param {Boolean} skipKeyedNodes If true then elements with keys will be skipped and not discarded.
|
370
|
-
* @return {undefined}
|
371
|
-
*/
|
372
|
-
function removeNode(node, parentNode, skipKeyedNodes) {
|
373
|
-
if (onBeforeNodeDiscarded(node) === false) {
|
374
|
-
return;
|
375
|
-
}
|
376
|
-
|
377
|
-
if (parentNode) {
|
378
|
-
parentNode.removeChild(node);
|
379
|
-
}
|
380
|
-
|
381
|
-
onNodeDiscarded(node);
|
382
|
-
walkDiscardedChildNodes(node, skipKeyedNodes);
|
383
|
-
}
|
384
|
-
|
385
|
-
// // TreeWalker implementation is no faster, but keeping this around in case this changes in the future
|
386
|
-
// function indexTree(root) {
|
387
|
-
// var treeWalker = document.createTreeWalker(
|
388
|
-
// root,
|
389
|
-
// NodeFilter.SHOW_ELEMENT);
|
390
|
-
//
|
391
|
-
// var el;
|
392
|
-
// while((el = treeWalker.nextNode())) {
|
393
|
-
// var key = getNodeKey(el);
|
394
|
-
// if (key) {
|
395
|
-
// fromNodesLookup[key] = el;
|
396
|
-
// }
|
397
|
-
// }
|
398
|
-
// }
|
399
|
-
|
400
|
-
// // NodeIterator implementation is no faster, but keeping this around in case this changes in the future
|
401
|
-
//
|
402
|
-
// function indexTree(node) {
|
403
|
-
// var nodeIterator = document.createNodeIterator(node, NodeFilter.SHOW_ELEMENT);
|
404
|
-
// var el;
|
405
|
-
// while((el = nodeIterator.nextNode())) {
|
406
|
-
// var key = getNodeKey(el);
|
407
|
-
// if (key) {
|
408
|
-
// fromNodesLookup[key] = el;
|
409
|
-
// }
|
410
|
-
// }
|
411
|
-
// }
|
412
|
-
|
413
|
-
function indexTree(node) {
|
414
|
-
if (node.nodeType === ELEMENT_NODE || node.nodeType === DOCUMENT_FRAGMENT_NODE$1) {
|
415
|
-
var curChild = node.firstChild;
|
416
|
-
while (curChild) {
|
417
|
-
var key = getNodeKey(curChild);
|
418
|
-
if (key) {
|
419
|
-
fromNodesLookup[key] = curChild;
|
420
|
-
}
|
421
|
-
|
422
|
-
// Walk recursively
|
423
|
-
indexTree(curChild);
|
424
|
-
|
425
|
-
curChild = curChild.nextSibling;
|
426
|
-
}
|
427
|
-
}
|
428
|
-
}
|
429
|
-
|
430
|
-
indexTree(fromNode);
|
431
|
-
|
432
|
-
function handleNodeAdded(el) {
|
433
|
-
onNodeAdded(el);
|
434
|
-
|
435
|
-
var curChild = el.firstChild;
|
436
|
-
while (curChild) {
|
437
|
-
var nextSibling = curChild.nextSibling;
|
438
|
-
|
439
|
-
var key = getNodeKey(curChild);
|
440
|
-
if (key) {
|
441
|
-
var unmatchedFromEl = fromNodesLookup[key];
|
442
|
-
// if we find a duplicate #id node in cache, replace `el` with cache value
|
443
|
-
// and morph it to the child node.
|
444
|
-
if (unmatchedFromEl && compareNodeNames(curChild, unmatchedFromEl)) {
|
445
|
-
curChild.parentNode.replaceChild(unmatchedFromEl, curChild);
|
446
|
-
morphEl(unmatchedFromEl, curChild);
|
447
|
-
} else {
|
448
|
-
handleNodeAdded(curChild);
|
449
|
-
}
|
450
|
-
} else {
|
451
|
-
// recursively call for curChild and it's children to see if we find something in
|
452
|
-
// fromNodesLookup
|
453
|
-
handleNodeAdded(curChild);
|
454
|
-
}
|
455
|
-
|
456
|
-
curChild = nextSibling;
|
457
|
-
}
|
458
|
-
}
|
459
|
-
|
460
|
-
function cleanupFromEl(fromEl, curFromNodeChild, curFromNodeKey) {
|
461
|
-
// We have processed all of the "to nodes". If curFromNodeChild is
|
462
|
-
// non-null then we still have some from nodes left over that need
|
463
|
-
// to be removed
|
464
|
-
while (curFromNodeChild) {
|
465
|
-
var fromNextSibling = curFromNodeChild.nextSibling;
|
466
|
-
if ((curFromNodeKey = getNodeKey(curFromNodeChild))) {
|
467
|
-
// Since the node is keyed it might be matched up later so we defer
|
468
|
-
// the actual removal to later
|
469
|
-
addKeyedRemoval(curFromNodeKey);
|
470
|
-
} else {
|
471
|
-
// NOTE: we skip nested keyed nodes from being removed since there is
|
472
|
-
// still a chance they will be matched up later
|
473
|
-
removeNode(curFromNodeChild, fromEl, true /* skip keyed nodes */);
|
474
|
-
}
|
475
|
-
curFromNodeChild = fromNextSibling;
|
476
|
-
}
|
477
|
-
}
|
478
|
-
|
479
|
-
function morphEl(fromEl, toEl, childrenOnly) {
|
480
|
-
var toElKey = getNodeKey(toEl);
|
481
|
-
|
482
|
-
if (toElKey) {
|
483
|
-
// If an element with an ID is being morphed then it will be in the final
|
484
|
-
// DOM so clear it out of the saved elements collection
|
485
|
-
delete fromNodesLookup[toElKey];
|
486
|
-
}
|
487
|
-
|
488
|
-
if (!childrenOnly) {
|
489
|
-
// optional
|
490
|
-
if (onBeforeElUpdated(fromEl, toEl) === false) {
|
491
|
-
return;
|
492
|
-
}
|
493
|
-
|
494
|
-
// update attributes on original DOM element first
|
495
|
-
morphAttrs(fromEl, toEl);
|
496
|
-
// optional
|
497
|
-
onElUpdated(fromEl);
|
498
|
-
|
499
|
-
if (onBeforeElChildrenUpdated(fromEl, toEl) === false) {
|
500
|
-
return;
|
501
|
-
}
|
502
|
-
}
|
503
|
-
|
504
|
-
if (fromEl.nodeName !== 'TEXTAREA') {
|
505
|
-
morphChildren(fromEl, toEl);
|
506
|
-
} else {
|
507
|
-
specialElHandlers.TEXTAREA(fromEl, toEl);
|
508
|
-
}
|
509
|
-
}
|
510
|
-
|
511
|
-
function morphChildren(fromEl, toEl) {
|
512
|
-
var curToNodeChild = toEl.firstChild;
|
513
|
-
var curFromNodeChild = fromEl.firstChild;
|
514
|
-
var curToNodeKey;
|
515
|
-
var curFromNodeKey;
|
516
|
-
|
517
|
-
var fromNextSibling;
|
518
|
-
var toNextSibling;
|
519
|
-
var matchingFromEl;
|
520
|
-
|
521
|
-
// walk the children
|
522
|
-
outer: while (curToNodeChild) {
|
523
|
-
toNextSibling = curToNodeChild.nextSibling;
|
524
|
-
curToNodeKey = getNodeKey(curToNodeChild);
|
525
|
-
|
526
|
-
// walk the fromNode children all the way through
|
527
|
-
while (curFromNodeChild) {
|
528
|
-
fromNextSibling = curFromNodeChild.nextSibling;
|
529
|
-
|
530
|
-
if (curToNodeChild.isSameNode && curToNodeChild.isSameNode(curFromNodeChild)) {
|
531
|
-
curToNodeChild = toNextSibling;
|
532
|
-
curFromNodeChild = fromNextSibling;
|
533
|
-
continue outer;
|
534
|
-
}
|
535
|
-
|
536
|
-
curFromNodeKey = getNodeKey(curFromNodeChild);
|
537
|
-
|
538
|
-
var curFromNodeType = curFromNodeChild.nodeType;
|
539
|
-
|
540
|
-
// this means if the curFromNodeChild doesnt have a match with the curToNodeChild
|
541
|
-
var isCompatible = undefined;
|
542
|
-
|
543
|
-
if (curFromNodeType === curToNodeChild.nodeType) {
|
544
|
-
if (curFromNodeType === ELEMENT_NODE) {
|
545
|
-
// Both nodes being compared are Element nodes
|
546
|
-
|
547
|
-
if (curToNodeKey) {
|
548
|
-
// The target node has a key so we want to match it up with the correct element
|
549
|
-
// in the original DOM tree
|
550
|
-
if (curToNodeKey !== curFromNodeKey) {
|
551
|
-
// The current element in the original DOM tree does not have a matching key so
|
552
|
-
// let's check our lookup to see if there is a matching element in the original
|
553
|
-
// DOM tree
|
554
|
-
if ((matchingFromEl = fromNodesLookup[curToNodeKey])) {
|
555
|
-
if (fromNextSibling === matchingFromEl) {
|
556
|
-
// Special case for single element removals. To avoid removing the original
|
557
|
-
// DOM node out of the tree (since that can break CSS transitions, etc.),
|
558
|
-
// we will instead discard the current node and wait until the next
|
559
|
-
// iteration to properly match up the keyed target element with its matching
|
560
|
-
// element in the original tree
|
561
|
-
isCompatible = false;
|
562
|
-
} else {
|
563
|
-
// We found a matching keyed element somewhere in the original DOM tree.
|
564
|
-
// Let's move the original DOM node into the current position and morph
|
565
|
-
// it.
|
566
|
-
|
567
|
-
// NOTE: We use insertBefore instead of replaceChild because we want to go through
|
568
|
-
// the `removeNode()` function for the node that is being discarded so that
|
569
|
-
// all lifecycle hooks are correctly invoked
|
570
|
-
fromEl.insertBefore(matchingFromEl, curFromNodeChild);
|
571
|
-
|
572
|
-
// fromNextSibling = curFromNodeChild.nextSibling;
|
573
|
-
|
574
|
-
if (curFromNodeKey) {
|
575
|
-
// Since the node is keyed it might be matched up later so we defer
|
576
|
-
// the actual removal to later
|
577
|
-
addKeyedRemoval(curFromNodeKey);
|
578
|
-
} else {
|
579
|
-
// NOTE: we skip nested keyed nodes from being removed since there is
|
580
|
-
// still a chance they will be matched up later
|
581
|
-
removeNode(curFromNodeChild, fromEl, true /* skip keyed nodes */);
|
582
|
-
}
|
583
|
-
|
584
|
-
curFromNodeChild = matchingFromEl;
|
585
|
-
}
|
586
|
-
} else {
|
587
|
-
// The nodes are not compatible since the "to" node has a key and there
|
588
|
-
// is no matching keyed node in the source tree
|
589
|
-
isCompatible = false;
|
590
|
-
}
|
591
|
-
}
|
592
|
-
} else if (curFromNodeKey) {
|
593
|
-
// The original has a key
|
594
|
-
isCompatible = false;
|
595
|
-
}
|
596
|
-
|
597
|
-
isCompatible = isCompatible !== false && compareNodeNames(curFromNodeChild, curToNodeChild);
|
598
|
-
if (isCompatible) {
|
599
|
-
// We found compatible DOM elements so transform
|
600
|
-
// the current "from" node to match the current
|
601
|
-
// target DOM node.
|
602
|
-
// MORPH
|
603
|
-
morphEl(curFromNodeChild, curToNodeChild);
|
604
|
-
}
|
605
|
-
|
606
|
-
} else if (curFromNodeType === TEXT_NODE || curFromNodeType == COMMENT_NODE) {
|
607
|
-
// Both nodes being compared are Text or Comment nodes
|
608
|
-
isCompatible = true;
|
609
|
-
// Simply update nodeValue on the original node to
|
610
|
-
// change the text value
|
611
|
-
if (curFromNodeChild.nodeValue !== curToNodeChild.nodeValue) {
|
612
|
-
curFromNodeChild.nodeValue = curToNodeChild.nodeValue;
|
613
|
-
}
|
614
|
-
|
615
|
-
}
|
616
|
-
}
|
617
|
-
|
618
|
-
if (isCompatible) {
|
619
|
-
// Advance both the "to" child and the "from" child since we found a match
|
620
|
-
// Nothing else to do as we already recursively called morphChildren above
|
621
|
-
curToNodeChild = toNextSibling;
|
622
|
-
curFromNodeChild = fromNextSibling;
|
623
|
-
continue outer;
|
624
|
-
}
|
625
|
-
|
626
|
-
// No compatible match so remove the old node from the DOM and continue trying to find a
|
627
|
-
// match in the original DOM. However, we only do this if the from node is not keyed
|
628
|
-
// since it is possible that a keyed node might match up with a node somewhere else in the
|
629
|
-
// target tree and we don't want to discard it just yet since it still might find a
|
630
|
-
// home in the final DOM tree. After everything is done we will remove any keyed nodes
|
631
|
-
// that didn't find a home
|
632
|
-
if (curFromNodeKey) {
|
633
|
-
// Since the node is keyed it might be matched up later so we defer
|
634
|
-
// the actual removal to later
|
635
|
-
addKeyedRemoval(curFromNodeKey);
|
636
|
-
} else {
|
637
|
-
// NOTE: we skip nested keyed nodes from being removed since there is
|
638
|
-
// still a chance they will be matched up later
|
639
|
-
removeNode(curFromNodeChild, fromEl, true /* skip keyed nodes */);
|
640
|
-
}
|
641
|
-
|
642
|
-
curFromNodeChild = fromNextSibling;
|
643
|
-
} // END: while(curFromNodeChild) {}
|
644
|
-
|
645
|
-
// If we got this far then we did not find a candidate match for
|
646
|
-
// our "to node" and we exhausted all of the children "from"
|
647
|
-
// nodes. Therefore, we will just append the current "to" node
|
648
|
-
// to the end
|
649
|
-
if (curToNodeKey && (matchingFromEl = fromNodesLookup[curToNodeKey]) && compareNodeNames(matchingFromEl, curToNodeChild)) {
|
650
|
-
fromEl.appendChild(matchingFromEl);
|
651
|
-
// MORPH
|
652
|
-
morphEl(matchingFromEl, curToNodeChild);
|
653
|
-
} else {
|
654
|
-
var onBeforeNodeAddedResult = onBeforeNodeAdded(curToNodeChild);
|
655
|
-
if (onBeforeNodeAddedResult !== false) {
|
656
|
-
if (onBeforeNodeAddedResult) {
|
657
|
-
curToNodeChild = onBeforeNodeAddedResult;
|
658
|
-
}
|
659
|
-
|
660
|
-
if (curToNodeChild.actualize) {
|
661
|
-
curToNodeChild = curToNodeChild.actualize(fromEl.ownerDocument || doc);
|
662
|
-
}
|
663
|
-
fromEl.appendChild(curToNodeChild);
|
664
|
-
handleNodeAdded(curToNodeChild);
|
665
|
-
}
|
666
|
-
}
|
667
|
-
|
668
|
-
curToNodeChild = toNextSibling;
|
669
|
-
curFromNodeChild = fromNextSibling;
|
670
|
-
}
|
671
|
-
|
672
|
-
cleanupFromEl(fromEl, curFromNodeChild, curFromNodeKey);
|
673
|
-
|
674
|
-
var specialElHandler = specialElHandlers[fromEl.nodeName];
|
675
|
-
if (specialElHandler) {
|
676
|
-
specialElHandler(fromEl, toEl);
|
677
|
-
}
|
678
|
-
} // END: morphChildren(...)
|
679
|
-
|
680
|
-
var morphedNode = fromNode;
|
681
|
-
var morphedNodeType = morphedNode.nodeType;
|
682
|
-
var toNodeType = toNode.nodeType;
|
683
|
-
|
684
|
-
if (!childrenOnly) {
|
685
|
-
// Handle the case where we are given two DOM nodes that are not
|
686
|
-
// compatible (e.g. <div> --> <span> or <div> --> TEXT)
|
687
|
-
if (morphedNodeType === ELEMENT_NODE) {
|
688
|
-
if (toNodeType === ELEMENT_NODE) {
|
689
|
-
if (!compareNodeNames(fromNode, toNode)) {
|
690
|
-
onNodeDiscarded(fromNode);
|
691
|
-
morphedNode = moveChildren(fromNode, createElementNS(toNode.nodeName, toNode.namespaceURI));
|
692
|
-
}
|
693
|
-
} else {
|
694
|
-
// Going from an element node to a text node
|
695
|
-
morphedNode = toNode;
|
696
|
-
}
|
697
|
-
} else if (morphedNodeType === TEXT_NODE || morphedNodeType === COMMENT_NODE) { // Text or comment node
|
698
|
-
if (toNodeType === morphedNodeType) {
|
699
|
-
if (morphedNode.nodeValue !== toNode.nodeValue) {
|
700
|
-
morphedNode.nodeValue = toNode.nodeValue;
|
701
|
-
}
|
702
|
-
|
703
|
-
return morphedNode;
|
704
|
-
} else {
|
705
|
-
// Text node to something else
|
706
|
-
morphedNode = toNode;
|
707
|
-
}
|
708
|
-
}
|
709
|
-
}
|
710
|
-
|
711
|
-
if (morphedNode === toNode) {
|
712
|
-
// The "to node" was not compatible with the "from node" so we had to
|
713
|
-
// toss out the "from node" and use the "to node"
|
714
|
-
onNodeDiscarded(fromNode);
|
715
|
-
} else {
|
716
|
-
if (toNode.isSameNode && toNode.isSameNode(morphedNode)) {
|
717
|
-
return;
|
718
|
-
}
|
719
|
-
|
720
|
-
morphEl(morphedNode, toNode, childrenOnly);
|
721
|
-
|
722
|
-
// We now need to loop over any keyed nodes that might need to be
|
723
|
-
// removed. We only do the removal if we know that the keyed node
|
724
|
-
// never found a match. When a keyed node is matched up we remove
|
725
|
-
// it out of fromNodesLookup and we use fromNodesLookup to determine
|
726
|
-
// if a keyed node has been matched up or not
|
727
|
-
if (keyedRemovalList) {
|
728
|
-
for (var i=0, len=keyedRemovalList.length; i<len; i++) {
|
729
|
-
var elToRemove = fromNodesLookup[keyedRemovalList[i]];
|
730
|
-
if (elToRemove) {
|
731
|
-
removeNode(elToRemove, elToRemove.parentNode, false);
|
732
|
-
}
|
733
|
-
}
|
734
|
-
}
|
735
|
-
}
|
736
|
-
|
737
|
-
if (!childrenOnly && morphedNode !== fromNode && fromNode.parentNode) {
|
738
|
-
if (morphedNode.actualize) {
|
739
|
-
morphedNode = morphedNode.actualize(fromNode.ownerDocument || doc);
|
740
|
-
}
|
741
|
-
// If we had to swap out the from node with a new node because the old
|
742
|
-
// node was not compatible with the target node then we need to
|
743
|
-
// replace the old DOM node in the original DOM tree. This is only
|
744
|
-
// possible if the original DOM node was part of a DOM tree which
|
745
|
-
// we know is the case if it has a parent node.
|
746
|
-
fromNode.parentNode.replaceChild(morphedNode, fromNode);
|
747
|
-
}
|
748
|
-
|
749
|
-
return morphedNode;
|
750
|
-
};
|
751
|
-
}
|
752
|
-
|
753
|
-
var morphdom = morphdomFactory(morphAttrs);
|
754
|
-
|
755
|
-
export default morphdom;
|