domino 2.1.5 → 2.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/lib/ChildNode.js~ +27 -0
- package/lib/ContainerNode.js~ +52 -0
- package/lib/DOMTokenList.js +16 -2
- package/lib/LinkedList.js~ +21 -0
- package/lib/NamedNodeMap.js~ +23 -0
- package/lib/NavigatorID.js~ +17 -0
- package/lib/NodeIterator.js~ +71 -0
- package/lib/NodeList.es5.js~ +33 -0
- package/lib/NodeList.es6.js~ +33 -0
- package/lib/NodeList2.js.bak +21 -0
- package/lib/NodeList2.js~ +7 -0
- package/lib/NodeTraversal.js~ +31 -0
- package/lib/WindowTimers.js~ +11 -0
- package/lib/cssparser.js +6131 -5376
- package/lib/sloppy.js~ +9 -0
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
# domino 2.1.7 (26 Mar 2026)
|
|
2
|
+
* Updated CSS parser to latest upstream from
|
|
3
|
+
https://github.com/CSSLint/parser-lib including basic support for
|
|
4
|
+
CSS custom properties.
|
|
5
|
+
|
|
6
|
+
# domino 2.1.6 (16 Jul 2020)
|
|
7
|
+
* Bumped version of lodash (#169)
|
|
8
|
+
* Performance improvement to DOMTokenList (#166)
|
|
9
|
+
* `mocha` dependency has been updated to 6.x. As a result, we are
|
|
10
|
+
no longer testing on node 4.
|
|
11
|
+
|
|
1
12
|
# domino 2.1.5 (30 Apr 2020)
|
|
2
13
|
* Bumped version of jquery dev dependency (#163)
|
|
3
14
|
* Omit tests/ directory from NPM package (#161)
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// The ChildNode interface contains methods that are particular to `Node`
|
|
4
|
+
// objects that can have a parent. It is implemented by `Element`,
|
|
5
|
+
// `DocumentType`, and `CharacterData` objects.
|
|
6
|
+
var ChildNode = {
|
|
7
|
+
|
|
8
|
+
// Remove this node from its parent
|
|
9
|
+
remove: { value: function remove() {
|
|
10
|
+
if (this.parentNode === null) return;
|
|
11
|
+
|
|
12
|
+
// Send mutation events if necessary
|
|
13
|
+
if (this.rooted && this.doc) this.doc.mutateRemove(this);
|
|
14
|
+
|
|
15
|
+
// Remove this node from its parents array of children
|
|
16
|
+
this.parentNode.childNodes.splice(this.index, 1);
|
|
17
|
+
|
|
18
|
+
// Update the structure id for all ancestors
|
|
19
|
+
this.parentNode.modify();
|
|
20
|
+
|
|
21
|
+
// Forget this node's parent
|
|
22
|
+
this.parentNode = null;
|
|
23
|
+
}},
|
|
24
|
+
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
module.exports = ChildNode;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
module.exports = ContainerNode;
|
|
3
|
+
|
|
4
|
+
var Node = require('./Node');
|
|
5
|
+
var utils = require('./utils');
|
|
6
|
+
|
|
7
|
+
// This class defines common functionality for node subtypes that
|
|
8
|
+
// can have children
|
|
9
|
+
|
|
10
|
+
function ContainerNode() {
|
|
11
|
+
this._firstChild = this._childNodes = null;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// Primary representation is a circular linked list of siblings
|
|
15
|
+
ContainerNode.prototype = Object.create(Node.prototype, {
|
|
16
|
+
hasChildNodes: { value: function() {
|
|
17
|
+
if (this._childNodes) {
|
|
18
|
+
return this._childNodes.length > 0;
|
|
19
|
+
}
|
|
20
|
+
return this._firstChild !== null;
|
|
21
|
+
}},
|
|
22
|
+
childNodes: { get: function() {
|
|
23
|
+
this._ensureChildNodes();
|
|
24
|
+
return this._childNodes;
|
|
25
|
+
}},
|
|
26
|
+
firstChild: { value: function() {
|
|
27
|
+
if (this._childNodes) {
|
|
28
|
+
return this._childNodes.length === 0 ? null : this._childNodes[0];
|
|
29
|
+
}
|
|
30
|
+
return this._firstChild;
|
|
31
|
+
}},
|
|
32
|
+
lastChild: { value: function() {
|
|
33
|
+
var kids = this._childNodes, first;
|
|
34
|
+
if (kids) {
|
|
35
|
+
return kids.length === 0 ? null: kids[kids.length-1];
|
|
36
|
+
}
|
|
37
|
+
first = this._firstChild;
|
|
38
|
+
if (first === null) { return null; }
|
|
39
|
+
return first._previousChild; // circular linked list
|
|
40
|
+
}},
|
|
41
|
+
_ensureChildNodes: { value: function() {
|
|
42
|
+
if (this._childNodes) { return; }
|
|
43
|
+
var first = this._firstChild,
|
|
44
|
+
kid = first,
|
|
45
|
+
childNodes = this._childNodes = [];
|
|
46
|
+
if (first) do {
|
|
47
|
+
childNodes.push(kid);
|
|
48
|
+
kid = kid._nextSibling;
|
|
49
|
+
} while (kid !== first); // circular linked list
|
|
50
|
+
this._firstChild = null; // free memory
|
|
51
|
+
}}
|
|
52
|
+
});
|
package/lib/DOMTokenList.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// DOMTokenList implementation based on https://github.com/Raynos/DOM-shim
|
|
3
|
-
// XXX: should cache the getList(this) value more aggressively!
|
|
4
3
|
var utils = require('./utils');
|
|
5
4
|
|
|
6
5
|
module.exports = DOMTokenList;
|
|
@@ -9,6 +8,7 @@ function DOMTokenList(getter, setter) {
|
|
|
9
8
|
this._getString = getter;
|
|
10
9
|
this._setString = setter;
|
|
11
10
|
this._length = 0;
|
|
11
|
+
this._lastStringValue = '';
|
|
12
12
|
this._update();
|
|
13
13
|
}
|
|
14
14
|
|
|
@@ -129,6 +129,7 @@ Object.defineProperties(DOMTokenList.prototype, {
|
|
|
129
129
|
} else {
|
|
130
130
|
fixIndex(this, getList(this));
|
|
131
131
|
}
|
|
132
|
+
this._lastStringValue = this._getString();
|
|
132
133
|
} },
|
|
133
134
|
});
|
|
134
135
|
|
|
@@ -156,8 +157,21 @@ function handleErrors(token) {
|
|
|
156
157
|
return token;
|
|
157
158
|
}
|
|
158
159
|
|
|
160
|
+
function toArray(clist) {
|
|
161
|
+
var length = clist._length;
|
|
162
|
+
var arr = Array(length);
|
|
163
|
+
for (var i = 0; i < length; i++) {
|
|
164
|
+
arr[i] = clist[i];
|
|
165
|
+
}
|
|
166
|
+
return arr;
|
|
167
|
+
}
|
|
168
|
+
|
|
159
169
|
function getList(clist) {
|
|
160
|
-
var
|
|
170
|
+
var strProp = clist._getString();
|
|
171
|
+
if (strProp === clist._lastStringValue) {
|
|
172
|
+
return toArray(clist);
|
|
173
|
+
}
|
|
174
|
+
var str = strProp.replace(/(^[ \t\r\n\f]+)|([ \t\r\n\f]+$)/g, '');
|
|
161
175
|
if (str === "") {
|
|
162
176
|
return [];
|
|
163
177
|
} else {
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var LinkedList = module.exports.LinkedList = {
|
|
4
|
+
// insert a before b
|
|
5
|
+
insertBefore: function(a, b) {
|
|
6
|
+
var a_first = a, a_last = a._previousSibling;
|
|
7
|
+
var b_first = b, b_last = b._previousSibling;
|
|
8
|
+
a_first._previousSibling = b_last;
|
|
9
|
+
a_last._nextSibling = b_first;
|
|
10
|
+
b_last._nextSibling = a_first;
|
|
11
|
+
b_first._previousSibling = a_last;
|
|
12
|
+
},
|
|
13
|
+
// remove single node a from a list
|
|
14
|
+
remove: function(a, b) {
|
|
15
|
+
var prev = a._previousSibling;
|
|
16
|
+
var next = a._nextSibling;
|
|
17
|
+
prev._nextSibling = next;
|
|
18
|
+
next._previousSibling = prev;
|
|
19
|
+
a._previousSibling = a._nextSibling = a;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
module.exports = NamedNodeMap;
|
|
3
|
+
|
|
4
|
+
var utils = require('./utils');
|
|
5
|
+
|
|
6
|
+
/* This is a hacky implementation of NamedNodeMap, intended primarily to
|
|
7
|
+
* satisfy clients (like dompurify and the web-platform-tests) which check
|
|
8
|
+
* to ensure that Node#attributes instanceof NamedNodeMap. */
|
|
9
|
+
|
|
10
|
+
function NamedNodeMap(element) {
|
|
11
|
+
this.element = element;
|
|
12
|
+
}
|
|
13
|
+
Object.defineProperties(NamedNodeMap.prototype, {
|
|
14
|
+
length: { get: function length() { utils.shouldOverride(); } },
|
|
15
|
+
item: { value: function item(index) { utils.shouldOverride(); } },
|
|
16
|
+
getNamedItem: { value: function getNamedItem(qualifiedName) {
|
|
17
|
+
return this.element.getAttributeNode(qualifiedName);
|
|
18
|
+
} },
|
|
19
|
+
getNamedItemNS: { value: function getNamedItemNS(namespace, localName) {
|
|
20
|
+
return this.element.getAttributeNodeNS(namespace, localName);
|
|
21
|
+
} },
|
|
22
|
+
|
|
23
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// https://html.spec.whatwg.org/multipage/webappapis.html#navigatorid
|
|
4
|
+
var NavigatorID = {
|
|
5
|
+
appCodeName: "Mozilla",
|
|
6
|
+
appName: "Netscape",
|
|
7
|
+
appVersion: "4.0",
|
|
8
|
+
platform: "",
|
|
9
|
+
product: "Gecko",
|
|
10
|
+
productSub: "20100101",
|
|
11
|
+
userAgent: "",
|
|
12
|
+
vendor: "",
|
|
13
|
+
vendorSub: "",
|
|
14
|
+
taintEnabled: function() { return false; }
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
module.exports = NavigatorID;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
module.exports = NodeIterator;
|
|
2
|
+
|
|
3
|
+
var NodeFilter = require('./NodeFilter');
|
|
4
|
+
|
|
5
|
+
/* Public API */
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Implemented version: http://www.w3.org/TR/2015/WD-dom-20150618/#nodeiterator
|
|
9
|
+
* Latest version: http://www.w3.org/TR/dom/#nodeiterator
|
|
10
|
+
*
|
|
11
|
+
* @constructor
|
|
12
|
+
* @param {Node} root
|
|
13
|
+
* @param {number} whatToShow [optional]
|
|
14
|
+
* @param {Function|NodeFilter} filter [optional]
|
|
15
|
+
* @throws Error
|
|
16
|
+
*/
|
|
17
|
+
function NodeIterator(root, whatToShow, filter) {
|
|
18
|
+
var ni = this, active = false;
|
|
19
|
+
|
|
20
|
+
if (!root || !root.nodeType) {
|
|
21
|
+
throw new Error('DOMException: NOT_SUPPORTED_ERR');
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
ni.root = ni.referenceNode = root;
|
|
25
|
+
ni.pointerBeforeReferenceNode = true;
|
|
26
|
+
ni.whatToShow = Number(whatToShow) || 0;
|
|
27
|
+
|
|
28
|
+
if (typeof filter !== 'function') {
|
|
29
|
+
// Allow filter to implement NodeFilter
|
|
30
|
+
if (filter && typeof filter === 'object' &&
|
|
31
|
+
typeof filter.acceptNode === 'function') {
|
|
32
|
+
filter = filter.acceptNode.bind(filter);
|
|
33
|
+
} else {
|
|
34
|
+
filter = null;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
ni.filter = Object.create(NodeFilter.prototype);
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @method
|
|
42
|
+
* @param {Node} node
|
|
43
|
+
* @return {Number} Constant NodeFilter.FILTER_ACCEPT,
|
|
44
|
+
* NodeFilter.FILTER_REJECT or NodeFilter.FILTER_SKIP.
|
|
45
|
+
*/
|
|
46
|
+
ni.filter.acceptNode = function (node) {
|
|
47
|
+
var result;
|
|
48
|
+
if (active) {
|
|
49
|
+
throw new Error('DOMException: INVALID_STATE_ERR');
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Maps nodeType to whatToShow
|
|
53
|
+
if (!(((1 << (node.nodeType - 1)) & tw.whatToShow))) {
|
|
54
|
+
return NodeFilter.FILTER_SKIP;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (filter === null) {
|
|
58
|
+
return NodeFilter.FILTER_ACCEPT;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
active = true;
|
|
62
|
+
result = filter(node);
|
|
63
|
+
active = false;
|
|
64
|
+
|
|
65
|
+
return result;
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
NodeIterator.prototype = {
|
|
70
|
+
constructor: NodeIterator,
|
|
71
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/* jshint esversion: 6 */
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
var NodeList;
|
|
5
|
+
|
|
6
|
+
// Attempt to use ES6-style Array subclass if possible.
|
|
7
|
+
try {
|
|
8
|
+
NodeList = class NodeList extends Array {
|
|
9
|
+
constructor(a) {
|
|
10
|
+
super((a && a.length) || 0);
|
|
11
|
+
if (a) {
|
|
12
|
+
for (var idx in a) { this[idx] = a[idx]; }
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
item(i) { return this[i] || null; }
|
|
16
|
+
};
|
|
17
|
+
} catch (e) {
|
|
18
|
+
console.log("using fallback");
|
|
19
|
+
|
|
20
|
+
// No support for subclassing array, return an actual Array object.
|
|
21
|
+
var item = function item(i) {
|
|
22
|
+
/* jshint validthis: true */
|
|
23
|
+
return this[i] || null;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
NodeList = function NodeList(a) {
|
|
27
|
+
if (!a) a = [];
|
|
28
|
+
a.item = item;
|
|
29
|
+
return a;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
module.exports = NodeList;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/* jshint esversion: 6 */
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
var NodeList;
|
|
5
|
+
|
|
6
|
+
// Attempt to use ES6-style Array subclass if possible.
|
|
7
|
+
try {
|
|
8
|
+
NodeList = class NodeList extends Array {
|
|
9
|
+
constructor(a) {
|
|
10
|
+
super((a && a.length) || 0);
|
|
11
|
+
if (a) {
|
|
12
|
+
for (var idx in a) { this[idx] = a[idx]; }
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
item(i) { return this[i] || null; }
|
|
16
|
+
};
|
|
17
|
+
} catch (e) {
|
|
18
|
+
console.log("using fallback");
|
|
19
|
+
|
|
20
|
+
// No support for subclassing array, return an actual Array object.
|
|
21
|
+
var item = function item(i) {
|
|
22
|
+
/* jshint validthis: true */
|
|
23
|
+
return this[i] || null;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
NodeList = function NodeList(a) {
|
|
27
|
+
if (!a) a = [];
|
|
28
|
+
a.item = item;
|
|
29
|
+
return a;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
module.exports = NodeList;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
class NodeList2 extends Array {
|
|
4
|
+
constructor() { super(); }
|
|
5
|
+
item(i) { return this[i]; }
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/*
|
|
9
|
+
var handler = {
|
|
10
|
+
get: function(target, name) {
|
|
11
|
+
if (name === 'item') return function(i) { return this.backing[i]; };
|
|
12
|
+
return target.backing[name];
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
class NodeList2 extends Proxy {
|
|
17
|
+
constructor() { super({backing:[]}, handler); }
|
|
18
|
+
}
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
module.exports = NodeList2;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
var NodeTraversal = module.exports = {};
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @based on WebKit's NodeTraversal::nextSkippingChildren
|
|
5
|
+
* https://trac.webkit.org/browser/trunk/Source/WebCore/dom/NodeTraversal.h?rev=179143#L109
|
|
6
|
+
*/
|
|
7
|
+
NodeTraversal.nextSkippingChildren = function(node, stayWithin) {
|
|
8
|
+
if (node === stayWithin) {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
if (node.nextSibling !== null) {
|
|
12
|
+
return node.nextSibling;
|
|
13
|
+
}
|
|
14
|
+
return NodeTraversal.nextAncestorSibling(node, stayWithin);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @based on WebKit's NodeTraversal::nextAncestorSibling
|
|
19
|
+
* https://trac.webkit.org/browser/trunk/Source/WebCore/dom/NodeTraversal.cpp?rev=179143#L93
|
|
20
|
+
*/
|
|
21
|
+
NodeTraversal.nextAncestorSibling = function(node, stayWithin) {
|
|
22
|
+
for (node = node.parentNode; node !== null; node = node.parentNode) {
|
|
23
|
+
if (node === stayWithin) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
if (node.nextSibling !== null) {
|
|
27
|
+
return node.nextSibling;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return null;
|
|
31
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// https://html.spec.whatwg.org/multipage/webappapis.html#windowtimers
|
|
4
|
+
var WindowTimers = {
|
|
5
|
+
setTimeout: setTimeout,
|
|
6
|
+
clearTimeout: clearTimeout,
|
|
7
|
+
setInterval: setInterval,
|
|
8
|
+
clearInterval: clearInterval
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
module.exports = WindowTimers;
|