-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathnode.js
More file actions
48 lines (47 loc) · 1.17 KB
/
Copy pathnode.js
File metadata and controls
48 lines (47 loc) · 1.17 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
45
46
47
48
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) {
cn.push(node);
}
};
},
createRange: function () {
return {
setStartBefore: function () {},
setEndAfter: function () {},
deleteContents: function () {}
};
}
},
childNodes: [],
insertBefore: function (before, after) {
var cn = this.childNodes;
var i = cn.indexOf(before);
if (-1 < i) cn.splice(i, 1);
if (after == null) cn.push(before);
else cn.splice(cn.indexOf(after), 0, before);
},
removeChild: function (child) {
var cn = this.childNodes;
cn.splice(cn.indexOf(child), 1);
}
}
};
require('./test.js');