-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathnode.js
More file actions
44 lines (43 loc) · 1.08 KB
/
Copy pathnode.js
File metadata and controls
44 lines (43 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
global.tressa = require('tressa');
global.Set = undefined;
global.domdiff = require('../cjs').default;
global.document = {
createTextNode: function (value) {
return Object.defineProperty(
{value: value},
'nextSibling',
{get: function () {
var cn = document.body.childNodes;
return cn[cn.indexOf(this) + 1] || null;
}}
);
},
body: {
ownerDocument: {
createDocumentFragment: function () {
var cn = [];
return {
appendChild: function (node) {
node.parentNode = this;
cn.push(node);
}
};
}
},
childNodes: [],
insertBefore: function (before, after) {
var cn = this.childNodes;
var i = cn.indexOf(before);
if (-1 < i) cn.splice(i, 1);
before.parentNode = this;
if (after == null) cn.push(before);
else cn.splice(cn.indexOf(after), 0, before);
},
removeChild: function (child) {
var cn = this.childNodes;
delete child.parentNode;
cn.splice(cn.indexOf(child), 1);
}
}
};
require('./test.js');