@remote-dom/polyfill 1.1.0 → 1.2.1
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 +12 -0
- package/build/cjs/Attr.cjs +55 -0
- package/build/cjs/CharacterData.cjs +30 -0
- package/build/cjs/ChildNode.cjs +47 -0
- package/build/cjs/Comment.cjs +13 -0
- package/build/cjs/CustomElementRegistry.cjs +43 -0
- package/build/cjs/CustomEvent.cjs +30 -0
- package/build/cjs/Document.cjs +107 -0
- package/build/cjs/DocumentFragment.cjs +14 -0
- package/build/cjs/Element.cjs +97 -0
- package/build/cjs/Event.cjs +115 -0
- package/build/cjs/EventTarget.cjs +108 -0
- package/build/cjs/HTMLBodyElement.cjs +9 -0
- package/build/cjs/HTMLElement.cjs +9 -0
- package/build/cjs/HTMLHeadElement.cjs +9 -0
- package/build/cjs/HTMLHtmlElement.cjs +9 -0
- package/build/cjs/HTMLTemplateElement.cjs +28 -0
- package/build/cjs/MutationObserver.cjs +9 -0
- package/build/cjs/NamedNodeMap.cjs +123 -0
- package/build/cjs/Node.cjs +116 -0
- package/build/cjs/NodeList.cjs +11 -0
- package/build/cjs/ParentNode.cjs +131 -0
- package/build/cjs/SVGElement.cjs +21 -0
- package/build/cjs/Text.cjs +13 -0
- package/build/cjs/Window.cjs +78 -0
- package/build/cjs/constants.cjs +59 -0
- package/build/cjs/index.cjs +13 -0
- package/build/cjs/selectors.cjs +203 -0
- package/build/cjs/serialization.cjs +99 -0
- package/build/cjs/shared.cjs +65 -0
- package/build/esm/Element.mjs +2 -4
- package/build/esm/NamedNodeMap.mjs +1 -1
- package/build/esm/constants.mjs +1 -2
- package/build/esnext/Element.esnext +2 -4
- package/build/esnext/NamedNodeMap.esnext +1 -1
- package/build/esnext/constants.esnext +1 -2
- package/build/tsconfig.tsbuildinfo +1 -1
- package/build/typescript/Element.d.ts +1 -2
- package/build/typescript/Element.d.ts.map +1 -1
- package/build/typescript/NamedNodeMap.d.ts.map +1 -1
- package/build/typescript/constants.d.ts +0 -1
- package/build/typescript/constants.d.ts.map +1 -1
- package/package.json +3 -2
- package/rollup.config.js +1 -1
- package/source/Element.ts +3 -4
- package/source/NamedNodeMap.ts +2 -1
- package/source/constants.ts +0 -1
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
const constants = require('./constants.cjs');
|
|
6
|
+
const shared = require('./shared.cjs');
|
|
7
|
+
|
|
8
|
+
var Combinator = /*#__PURE__*/function (Combinator) {
|
|
9
|
+
Combinator[Combinator["Descendant"] = 0] = "Descendant";
|
|
10
|
+
Combinator[Combinator["Child"] = 1] = "Child";
|
|
11
|
+
Combinator[Combinator["Sibling"] = 2] = "Sibling";
|
|
12
|
+
Combinator[Combinator["Adjacent"] = 3] = "Adjacent";
|
|
13
|
+
Combinator[Combinator["Inner"] = 4] = "Inner";
|
|
14
|
+
return Combinator;
|
|
15
|
+
}(Combinator || {});
|
|
16
|
+
var MatcherType = /*#__PURE__*/function (MatcherType) {
|
|
17
|
+
MatcherType[MatcherType["Unknown"] = 0] = "Unknown";
|
|
18
|
+
MatcherType[MatcherType["Element"] = 1] = "Element";
|
|
19
|
+
MatcherType[MatcherType["Id"] = 2] = "Id";
|
|
20
|
+
MatcherType[MatcherType["Class"] = 3] = "Class";
|
|
21
|
+
MatcherType[MatcherType["Attribute"] = 4] = "Attribute";
|
|
22
|
+
MatcherType[MatcherType["Pseudo"] = 5] = "Pseudo";
|
|
23
|
+
MatcherType[MatcherType["Function"] = 6] = "Function";
|
|
24
|
+
return MatcherType;
|
|
25
|
+
}(MatcherType || {});
|
|
26
|
+
const ELEMENT_SELECTOR_TEST = /[a-z]/;
|
|
27
|
+
function querySelector(within, selector) {
|
|
28
|
+
const parts = parseSelector(selector);
|
|
29
|
+
let result = null;
|
|
30
|
+
const child = within[constants.CHILD];
|
|
31
|
+
if (child && parts[0].matchers.length) {
|
|
32
|
+
walkNodesForSelector(child, parts, node => {
|
|
33
|
+
result = node;
|
|
34
|
+
return false;
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
return result;
|
|
38
|
+
}
|
|
39
|
+
function querySelectorAll(within, selector) {
|
|
40
|
+
const parts = parseSelector(selector);
|
|
41
|
+
const results = [];
|
|
42
|
+
const child = within[constants.CHILD];
|
|
43
|
+
if (child && parts[0].matchers.length) {
|
|
44
|
+
walkNodesForSelector(child, parts, node => {
|
|
45
|
+
results.push(node);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
return results;
|
|
49
|
+
}
|
|
50
|
+
function parseSelector(selector) {
|
|
51
|
+
let part = {
|
|
52
|
+
combinator: Combinator.Inner,
|
|
53
|
+
matchers: []
|
|
54
|
+
};
|
|
55
|
+
const parts = [part];
|
|
56
|
+
const tokenizer = /\s*?([>\s+~]?)\s*?(?:(?:\[\s*([^\]=]+)(?:=(['"])(.*?)\3)?\s*\])|([#.]?)([^\s#.[>:]+)|:(\w+)(?:\((.*?)\))?)/gi;
|
|
57
|
+
let token;
|
|
58
|
+
while (token = tokenizer.exec(selector)) {
|
|
59
|
+
// [1]: ancestor/parent/sibling/adjacent
|
|
60
|
+
// [2]: attribute name
|
|
61
|
+
// [4]: attribute value
|
|
62
|
+
// [5]: id/class sigil
|
|
63
|
+
// [6]: id/class name
|
|
64
|
+
// [7]: :pseudo/:function() name
|
|
65
|
+
// [8]: :function(argument) value
|
|
66
|
+
if (token[1]) {
|
|
67
|
+
// Update the combinator on the (now parent) Part:
|
|
68
|
+
if (token[1] === '>') part.combinator = Combinator.Child;else if (token[1] === '+') part.combinator = Combinator.Adjacent;else if (token[1] === '~') part.combinator = Combinator.Sibling;else part.combinator = Combinator.Descendant;
|
|
69
|
+
// Add a new Part for the next selector parts:
|
|
70
|
+
part = {
|
|
71
|
+
combinator: Combinator.Inner,
|
|
72
|
+
matchers: []
|
|
73
|
+
};
|
|
74
|
+
parts.push(part);
|
|
75
|
+
}
|
|
76
|
+
let type = MatcherType.Unknown;
|
|
77
|
+
if (token[2]) {
|
|
78
|
+
type = MatcherType.Attribute;
|
|
79
|
+
} else if (token[5]) {
|
|
80
|
+
type = token[5] === '#' ? MatcherType.Id : MatcherType.Class;
|
|
81
|
+
} else if (token[7]) {
|
|
82
|
+
type = token[8] == null ? MatcherType.Pseudo : MatcherType.Function;
|
|
83
|
+
} else if (token[6] && ELEMENT_SELECTOR_TEST.test(token[6])) {
|
|
84
|
+
type = MatcherType.Element;
|
|
85
|
+
}
|
|
86
|
+
part.matchers.push({
|
|
87
|
+
type,
|
|
88
|
+
name: token[2] || token[6] || token[7],
|
|
89
|
+
value: token[4] ?? token[6] ?? token[8]
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
return parts;
|
|
93
|
+
}
|
|
94
|
+
function matchesSelector(element, selector) {
|
|
95
|
+
const parsed = parseSelector(selector);
|
|
96
|
+
let part;
|
|
97
|
+
while (part = parsed.pop()) {
|
|
98
|
+
if (!matchesSelectorPart(element, part)) return false;
|
|
99
|
+
}
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
function walkNodesForSelector(node, parts, callback) {
|
|
103
|
+
if (shared.isElementNode(node)) {
|
|
104
|
+
if (matchesSelectorRecursive(node, parts)) {
|
|
105
|
+
if (callback(node) === false) return false;
|
|
106
|
+
}
|
|
107
|
+
const child = node[constants.CHILD];
|
|
108
|
+
if (child && walkNodesForSelector(child, parts, callback) === false) {
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
const next = node[constants.NEXT];
|
|
113
|
+
if (next && walkNodesForSelector(next, parts, callback) === false) {
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
return true;
|
|
117
|
+
}
|
|
118
|
+
function matchesSelectorRecursive(element, parts) {
|
|
119
|
+
const {
|
|
120
|
+
combinator,
|
|
121
|
+
matchers
|
|
122
|
+
} = parts[parts.length - 1];
|
|
123
|
+
if (combinator === Combinator.Inner) {
|
|
124
|
+
if (!matchesSelectorMatcher(element, matchers)) return false;
|
|
125
|
+
const pp = parts.slice(0, -1);
|
|
126
|
+
return pp.length === 0 || matchesSelectorRecursive(element, pp);
|
|
127
|
+
}
|
|
128
|
+
const link = combinator === Combinator.Child || combinator === Combinator.Descendant ? constants.PARENT : constants.PREV;
|
|
129
|
+
let ref = element[link];
|
|
130
|
+
if (!ref || !matchesSelectorMatcher(ref, matchers)) {
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
if (combinator === Combinator.Descendant || combinator === Combinator.Sibling) {
|
|
134
|
+
while (ref = ref[link]) {
|
|
135
|
+
if (matchesSelectorMatcher(ref, matchers)) {
|
|
136
|
+
const pp = parts.slice(0, -1);
|
|
137
|
+
if (pp.length === 0) return true;
|
|
138
|
+
if (matchesSelectorRecursive(element, pp)) return true;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return false;
|
|
143
|
+
}
|
|
144
|
+
function matchesSelectorPart(element, {
|
|
145
|
+
combinator,
|
|
146
|
+
matchers
|
|
147
|
+
}) {
|
|
148
|
+
if (combinator === Combinator.Inner) {
|
|
149
|
+
return matchesSelectorMatcher(element, matchers);
|
|
150
|
+
}
|
|
151
|
+
const link = combinator === Combinator.Child || combinator === Combinator.Descendant ? constants.PARENT : constants.PREV;
|
|
152
|
+
let ref = element[link];
|
|
153
|
+
if (!ref || !matchesSelectorMatcher(ref, matchers)) {
|
|
154
|
+
return false;
|
|
155
|
+
}
|
|
156
|
+
if (combinator === Combinator.Descendant || combinator === Combinator.Sibling) {
|
|
157
|
+
while (ref = ref[link]) {
|
|
158
|
+
if (matchesSelectorMatcher(ref, matchers)) return true;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
return false;
|
|
162
|
+
}
|
|
163
|
+
function matchesSelectorMatcher(element, matcher) {
|
|
164
|
+
if (!element) return false;
|
|
165
|
+
if (Array.isArray(matcher)) {
|
|
166
|
+
for (const single of matcher) {
|
|
167
|
+
if (matchesSelectorMatcher(element, single) === false) return false;
|
|
168
|
+
}
|
|
169
|
+
return true;
|
|
170
|
+
}
|
|
171
|
+
const {
|
|
172
|
+
type,
|
|
173
|
+
name,
|
|
174
|
+
value
|
|
175
|
+
} = matcher;
|
|
176
|
+
switch (type) {
|
|
177
|
+
case MatcherType.Element:
|
|
178
|
+
return element.localName === name;
|
|
179
|
+
case MatcherType.Id:
|
|
180
|
+
return element.getAttribute('id') === name;
|
|
181
|
+
case MatcherType.Class:
|
|
182
|
+
return element.getAttribute('class') === name;
|
|
183
|
+
case MatcherType.Attribute:
|
|
184
|
+
return value == null ? element.hasAttribute(name) : element.getAttribute(name) === value;
|
|
185
|
+
case MatcherType.Pseudo:
|
|
186
|
+
switch (name) {
|
|
187
|
+
default:
|
|
188
|
+
throw Error(`Pseudo :${name} not implemented`);
|
|
189
|
+
}
|
|
190
|
+
case MatcherType.Function:
|
|
191
|
+
switch (name) {
|
|
192
|
+
case 'has':
|
|
193
|
+
return matchesSelector(element, value || '');
|
|
194
|
+
default:
|
|
195
|
+
throw Error(`Function :${name}(${value}) not implemented`);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
return false;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
exports.parseSelector = parseSelector;
|
|
202
|
+
exports.querySelector = querySelector;
|
|
203
|
+
exports.querySelectorAll = querySelectorAll;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
const constants = require('./constants.cjs');
|
|
6
|
+
|
|
7
|
+
// const voidElements = {
|
|
8
|
+
// img: true,
|
|
9
|
+
// image: true,
|
|
10
|
+
// };
|
|
11
|
+
// const elementTokenizer =
|
|
12
|
+
// /(?:<([a-z][a-z0-9-:]*)( [^<>'"\n=\s]+=(['"])[^>'"\n]*\3)*\s*(\/?)\s*>|<\/([a-z][a-z0-9-:]*)>|([^&<>]+))/gi;
|
|
13
|
+
// const attributeTokenizer = / ([^<>'"\n=\s]+)=(['"])([^>'"\n]*)\2/g;
|
|
14
|
+
|
|
15
|
+
const elementTokenizer = /(?:<([a-z][a-z0-9-:]*)((?:\s[^<>'"=\n\s]+(?:=(['"])[^\n]*?\3|=[^>'"\n\s]*|))*)\s*(\/?)\s*>|<\/([a-z][a-z0-9-:]*)>|<!--(.*?)-->|([^&<>]+))/gi;
|
|
16
|
+
const attributeTokenizer = /\s([^<>'"=\n\s]+)(?:=(['"])([^\n]*?)\2|=([^>'"\n\s]*)|)/g;
|
|
17
|
+
function parseHtml(html, contextNode) {
|
|
18
|
+
const document = contextNode.ownerDocument;
|
|
19
|
+
const root = document.createDocumentFragment();
|
|
20
|
+
const stack = [root];
|
|
21
|
+
let parent = root;
|
|
22
|
+
let token;
|
|
23
|
+
elementTokenizer.lastIndex = 0;
|
|
24
|
+
while (token = elementTokenizer.exec(html)) {
|
|
25
|
+
const tag = token[1];
|
|
26
|
+
if (tag) {
|
|
27
|
+
const node = document.createElement(tag);
|
|
28
|
+
const attrs = token[2];
|
|
29
|
+
attributeTokenizer.lastIndex = 0;
|
|
30
|
+
let t;
|
|
31
|
+
while (t = attributeTokenizer.exec(attrs)) {
|
|
32
|
+
node.setAttribute(t[1], t[3] || t[4] || '');
|
|
33
|
+
}
|
|
34
|
+
parent.append(node);
|
|
35
|
+
// if (voidElements[tag] === true) continue;
|
|
36
|
+
stack.push(parent);
|
|
37
|
+
parent = node;
|
|
38
|
+
} else if (token[5]) {
|
|
39
|
+
parent = stack.pop() || root;
|
|
40
|
+
} else if (token[6]) {
|
|
41
|
+
parent.append(document.createComment(token[6]));
|
|
42
|
+
} else {
|
|
43
|
+
parent.append(token[7]);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return root;
|
|
47
|
+
}
|
|
48
|
+
function serializeChildren(parentNode) {
|
|
49
|
+
let out = '';
|
|
50
|
+
let child = parentNode[constants.CHILD];
|
|
51
|
+
while (child) {
|
|
52
|
+
out += serializeNode(child);
|
|
53
|
+
child = child[constants.NEXT];
|
|
54
|
+
}
|
|
55
|
+
return out;
|
|
56
|
+
}
|
|
57
|
+
function serializeNode(node) {
|
|
58
|
+
switch (node.nodeType) {
|
|
59
|
+
case constants.NodeType.ELEMENT_NODE:
|
|
60
|
+
{
|
|
61
|
+
const el = node;
|
|
62
|
+
let out = `<${el[constants.NAME]}`;
|
|
63
|
+
let attr = el[constants.ATTRIBUTES]?.[constants.CHILD];
|
|
64
|
+
while (attr) {
|
|
65
|
+
out += ` ${attr[constants.NAME]}`;
|
|
66
|
+
let value = attr[constants.VALUE];
|
|
67
|
+
if (value !== '') {
|
|
68
|
+
value = String(value).replace(/&/g, '&').replace(/"/g, '"');
|
|
69
|
+
out += `="${value}"`;
|
|
70
|
+
}
|
|
71
|
+
attr = attr[constants.NEXT];
|
|
72
|
+
}
|
|
73
|
+
out += '>';
|
|
74
|
+
out += serializeChildren(el);
|
|
75
|
+
// let child = el[CHILD];
|
|
76
|
+
// while (child) {
|
|
77
|
+
// out += serialize(child);
|
|
78
|
+
// child = child[NEXT];
|
|
79
|
+
// }
|
|
80
|
+
out += `</${el[constants.NAME]}>`;
|
|
81
|
+
return out;
|
|
82
|
+
}
|
|
83
|
+
case constants.NodeType.TEXT_NODE:
|
|
84
|
+
{
|
|
85
|
+
const text = node;
|
|
86
|
+
return text[constants.DATA].replace(/&/g, '&').replace(/"/g, '"').replace(/</g, '<').replace(/>/g, '>');
|
|
87
|
+
}
|
|
88
|
+
case constants.NodeType.COMMENT_NODE:
|
|
89
|
+
{
|
|
90
|
+
const text = node;
|
|
91
|
+
return `<!--${text[constants.DATA]}-->`;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return '';
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
exports.parseHtml = parseHtml;
|
|
98
|
+
exports.serializeChildren = serializeChildren;
|
|
99
|
+
exports.serializeNode = serializeNode;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
const constants = require('./constants.cjs');
|
|
6
|
+
|
|
7
|
+
function isCharacterData(node) {
|
|
8
|
+
return constants.DATA in node;
|
|
9
|
+
}
|
|
10
|
+
function isTextNode(node) {
|
|
11
|
+
return node.nodeType === constants.NodeType.TEXT_NODE;
|
|
12
|
+
}
|
|
13
|
+
function isCommentNode(node) {
|
|
14
|
+
return node.nodeType === constants.NodeType.COMMENT_NODE;
|
|
15
|
+
}
|
|
16
|
+
function isElementNode(node) {
|
|
17
|
+
return node.nodeType === constants.NodeType.ELEMENT_NODE;
|
|
18
|
+
}
|
|
19
|
+
function isDocumentFragmentNode(node) {
|
|
20
|
+
return node.nodeType === constants.NodeType.DOCUMENT_FRAGMENT_NODE;
|
|
21
|
+
}
|
|
22
|
+
function isParentNode(node) {
|
|
23
|
+
return 'appendChild' in node;
|
|
24
|
+
}
|
|
25
|
+
function cloneNode(node, deep, document = node.ownerDocument) {
|
|
26
|
+
if (isTextNode(node)) {
|
|
27
|
+
return document.createTextNode(node.data);
|
|
28
|
+
} else if (isCommentNode(node)) {
|
|
29
|
+
return document.createComment(node.data);
|
|
30
|
+
} else if (isElementNode(node)) {
|
|
31
|
+
const cloned = document.createElement(node.localName);
|
|
32
|
+
if (node[constants.ATTRIBUTES]) {
|
|
33
|
+
for (let i = 0; i < node[constants.ATTRIBUTES].length; i++) {
|
|
34
|
+
const attribute = node[constants.ATTRIBUTES].item(i);
|
|
35
|
+
cloned.setAttributeNS(attribute.namespaceURI, attribute.name, attribute.value);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
if (deep) {
|
|
39
|
+
for (const child of node.childNodes) {
|
|
40
|
+
cloned.appendChild(cloneNode(child, true, document));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return cloned;
|
|
44
|
+
} else if (isDocumentFragmentNode(node)) {
|
|
45
|
+
const fragment = document.createDocumentFragment();
|
|
46
|
+
if (deep) {
|
|
47
|
+
for (const child of node.childNodes) {
|
|
48
|
+
fragment.appendChild(cloneNode(child, true, document));
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return fragment;
|
|
52
|
+
} else {
|
|
53
|
+
const cloned = new node.constructor();
|
|
54
|
+
cloned[constants.OWNER_DOCUMENT] = document;
|
|
55
|
+
return cloned;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
exports.cloneNode = cloneNode;
|
|
60
|
+
exports.isCharacterData = isCharacterData;
|
|
61
|
+
exports.isCommentNode = isCommentNode;
|
|
62
|
+
exports.isDocumentFragmentNode = isDocumentFragmentNode;
|
|
63
|
+
exports.isElementNode = isElementNode;
|
|
64
|
+
exports.isParentNode = isParentNode;
|
|
65
|
+
exports.isTextNode = isTextNode;
|
package/build/esm/Element.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NodeType, NS, NamespaceURI,
|
|
1
|
+
import { NodeType, NS, NamespaceURI, ATTRIBUTES } from './constants.mjs';
|
|
2
2
|
import { ParentNode } from './ParentNode.mjs';
|
|
3
3
|
import { NamedNodeMap } from './NamedNodeMap.mjs';
|
|
4
4
|
import { Attr } from './Attr.mjs';
|
|
@@ -7,7 +7,6 @@ import { serializeNode, serializeChildren, parseHtml } from './serialization.mjs
|
|
|
7
7
|
class Element extends ParentNode {
|
|
8
8
|
nodeType = NodeType.ELEMENT_NODE;
|
|
9
9
|
[NS] = NamespaceURI.XHTML;
|
|
10
|
-
[SLOT] = '';
|
|
11
10
|
get namespaceURI() {
|
|
12
11
|
return this[NS];
|
|
13
12
|
}
|
|
@@ -15,11 +14,10 @@ class Element extends ParentNode {
|
|
|
15
14
|
return this.nodeName;
|
|
16
15
|
}
|
|
17
16
|
get slot() {
|
|
18
|
-
return this
|
|
17
|
+
return this.getAttribute('slot') ?? '';
|
|
19
18
|
}
|
|
20
19
|
set slot(slot) {
|
|
21
20
|
const finalSlot = String(slot);
|
|
22
|
-
this[SLOT] = finalSlot;
|
|
23
21
|
if (this.getAttribute('slot') !== finalSlot) {
|
|
24
22
|
this.attributes.setNamedItem(new Attr('slot', finalSlot));
|
|
25
23
|
}
|
|
@@ -107,7 +107,7 @@ function updateElementAttribute(element, name, oldValue, newValue) {
|
|
|
107
107
|
const {
|
|
108
108
|
attributeChangedCallback
|
|
109
109
|
} = element;
|
|
110
|
-
if (name === 'slot'
|
|
110
|
+
if (name === 'slot') {
|
|
111
111
|
element.slot = newValue ?? '';
|
|
112
112
|
}
|
|
113
113
|
if (attributeChangedCallback == null || observedAttributes == null || !observedAttributes.includes(name)) {
|
package/build/esm/constants.mjs
CHANGED
|
@@ -12,7 +12,6 @@ const DATA = Symbol('data');
|
|
|
12
12
|
const LISTENERS = Symbol('listeners');
|
|
13
13
|
const IS_TRUSTED = Symbol('isTrusted');
|
|
14
14
|
const CONTENT = Symbol('content');
|
|
15
|
-
const SLOT = Symbol('slot');
|
|
16
15
|
const HOOKS = Symbol('hooks');
|
|
17
16
|
|
|
18
17
|
// @TODO remove explicit values
|
|
@@ -37,4 +36,4 @@ let NamespaceURI = /*#__PURE__*/function (NamespaceURI) {
|
|
|
37
36
|
return NamespaceURI;
|
|
38
37
|
}({});
|
|
39
38
|
|
|
40
|
-
export { ATTRIBUTES, CHILD, CONTENT, DATA, HOOKS, IS_TRUSTED, LISTENERS, NAME, NEXT, NS, NamespaceURI, NodeType, OWNER_DOCUMENT, OWNER_ELEMENT, PARENT, PREV,
|
|
39
|
+
export { ATTRIBUTES, CHILD, CONTENT, DATA, HOOKS, IS_TRUSTED, LISTENERS, NAME, NEXT, NS, NamespaceURI, NodeType, OWNER_DOCUMENT, OWNER_ELEMENT, PARENT, PREV, VALUE };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NodeType, NS, NamespaceURI,
|
|
1
|
+
import { NodeType, NS, NamespaceURI, ATTRIBUTES } from './constants.esnext';
|
|
2
2
|
import { ParentNode } from './ParentNode.esnext';
|
|
3
3
|
import { NamedNodeMap } from './NamedNodeMap.esnext';
|
|
4
4
|
import { Attr } from './Attr.esnext';
|
|
@@ -8,7 +8,6 @@ class Element extends ParentNode {
|
|
|
8
8
|
static observedAttributes;
|
|
9
9
|
nodeType = NodeType.ELEMENT_NODE;
|
|
10
10
|
[NS] = NamespaceURI.XHTML;
|
|
11
|
-
[SLOT] = "";
|
|
12
11
|
get namespaceURI() {
|
|
13
12
|
return this[NS];
|
|
14
13
|
}
|
|
@@ -17,11 +16,10 @@ class Element extends ParentNode {
|
|
|
17
16
|
}
|
|
18
17
|
[ATTRIBUTES];
|
|
19
18
|
get slot() {
|
|
20
|
-
return this
|
|
19
|
+
return this.getAttribute("slot") ?? "";
|
|
21
20
|
}
|
|
22
21
|
set slot(slot) {
|
|
23
22
|
const finalSlot = String(slot);
|
|
24
|
-
this[SLOT] = finalSlot;
|
|
25
23
|
if (this.getAttribute("slot") !== finalSlot) {
|
|
26
24
|
this.attributes.setNamedItem(new Attr("slot", finalSlot));
|
|
27
25
|
}
|
|
@@ -115,7 +115,7 @@ class NamedNodeMap {
|
|
|
115
115
|
function updateElementAttribute(element, name, oldValue, newValue) {
|
|
116
116
|
const { observedAttributes } = element.constructor;
|
|
117
117
|
const { attributeChangedCallback } = element;
|
|
118
|
-
if (name === "slot"
|
|
118
|
+
if (name === "slot") {
|
|
119
119
|
element.slot = newValue ?? "";
|
|
120
120
|
}
|
|
121
121
|
if (attributeChangedCallback == null || observedAttributes == null || !observedAttributes.includes(name)) {
|
|
@@ -12,7 +12,6 @@ const DATA = Symbol("data");
|
|
|
12
12
|
const LISTENERS = Symbol("listeners");
|
|
13
13
|
const IS_TRUSTED = Symbol("isTrusted");
|
|
14
14
|
const CONTENT = Symbol("content");
|
|
15
|
-
const SLOT = Symbol("slot");
|
|
16
15
|
const HOOKS = Symbol("hooks");
|
|
17
16
|
var NodeType = /* @__PURE__ */ ((NodeType2) => {
|
|
18
17
|
NodeType2[NodeType2["NODE"] = 0] = "NODE";
|
|
@@ -35,4 +34,4 @@ var NamespaceURI = /* @__PURE__ */ ((NamespaceURI2) => {
|
|
|
35
34
|
return NamespaceURI2;
|
|
36
35
|
})(NamespaceURI || {});
|
|
37
36
|
|
|
38
|
-
export { ATTRIBUTES, CHILD, CONTENT, DATA, HOOKS, IS_TRUSTED, LISTENERS, NAME, NEXT, NS, NamespaceURI, NodeType, OWNER_DOCUMENT, OWNER_ELEMENT, PARENT, PREV,
|
|
37
|
+
export { ATTRIBUTES, CHILD, CONTENT, DATA, HOOKS, IS_TRUSTED, LISTENERS, NAME, NEXT, NS, NamespaceURI, NodeType, OWNER_DOCUMENT, OWNER_ELEMENT, PARENT, PREV, VALUE };
|