@jsenv/core 36.2.0 → 36.3.0
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/dist/babel_helpers/AsyncGenerator/AsyncGenerator.js +45 -35
- package/dist/babel_helpers/AwaitValue/AwaitValue.js +3 -3
- package/dist/babel_helpers/applyDecoratedDescriptor/applyDecoratedDescriptor.js +13 -13
- package/dist/babel_helpers/applyDecs/applyDecs.js +227 -42
- package/dist/babel_helpers/applyDecs2203/applyDecs2203.js +559 -418
- package/dist/babel_helpers/applyDecs2203R/applyDecs2203R.js +235 -87
- package/dist/babel_helpers/applyDecs2301/applyDecs2301.js +591 -456
- package/dist/babel_helpers/applyDecs2305/applyDecs2305.js +681 -0
- package/dist/babel_helpers/arrayLikeToArray/arrayLikeToArray.js +5 -5
- package/dist/babel_helpers/arrayWithHoles/arrayWithHoles.js +3 -3
- package/dist/babel_helpers/arrayWithoutHoles/arrayWithoutHoles.js +4 -4
- package/dist/babel_helpers/assertThisInitialized/assertThisInitialized.js +4 -4
- package/dist/babel_helpers/asyncGeneratorDelegate/asyncGeneratorDelegate.js +12 -4
- package/dist/babel_helpers/asyncIterator/asyncIterator.js +13 -11
- package/dist/babel_helpers/asyncToGenerator/asyncToGenerator.js +18 -17
- package/dist/babel_helpers/awaitAsyncGenerator/awaitAsyncGenerator.js +2 -1
- package/dist/babel_helpers/checkInRHS/checkInRHS.js +8 -5
- package/dist/babel_helpers/classApplyDescriptorDestructureSet/classApplyDescriptorDestructureSet.js +7 -7
- package/dist/babel_helpers/classApplyDescriptorGet/classApplyDescriptorGet.js +3 -3
- package/dist/babel_helpers/classApplyDescriptorSet/classApplyDescriptorSet.js +4 -4
- package/dist/babel_helpers/classCallCheck/classCallCheck.js +2 -2
- package/dist/babel_helpers/classCheckPrivateStaticAccess/classCheckPrivateStaticAccess.js +2 -2
- package/dist/babel_helpers/classCheckPrivateStaticFieldDescriptor/classCheckPrivateStaticFieldDescriptor.js +2 -2
- package/dist/babel_helpers/classExtractFieldDescriptor/classExtractFieldDescriptor.js +3 -3
- package/dist/babel_helpers/classNameTDZError/classNameTDZError.js +2 -2
- package/dist/babel_helpers/classPrivateFieldDestructureSet/classPrivateFieldDestructureSet.js +6 -5
- package/dist/babel_helpers/classPrivateFieldGet/classPrivateFieldGet.js +6 -5
- package/dist/babel_helpers/classPrivateFieldLooseBase/classPrivateFieldLooseBase.js +3 -3
- package/dist/babel_helpers/classPrivateFieldLooseKey/classPrivateFieldLooseKey.js +3 -3
- package/dist/babel_helpers/classPrivateFieldSet/classPrivateFieldSet.js +7 -6
- package/dist/babel_helpers/classPrivateMethodGet/classPrivateMethodGet.js +3 -3
- package/dist/babel_helpers/classPrivateMethodSet/classPrivateMethodSet.js +2 -2
- package/dist/babel_helpers/classStaticPrivateFieldSpecGet/classStaticPrivateFieldSpecGet.js +8 -7
- package/dist/babel_helpers/classStaticPrivateFieldSpecSet/classStaticPrivateFieldSpecSet.js +15 -9
- package/dist/babel_helpers/classStaticPrivateMethodGet/classStaticPrivateMethodGet.js +5 -4
- package/dist/babel_helpers/classStaticPrivateMethodSet/classStaticPrivateMethodSet.js +2 -2
- package/dist/babel_helpers/construct/construct.js +10 -9
- package/dist/babel_helpers/createClass/createClass.js +2 -3
- package/dist/babel_helpers/createForOfIteratorHelper/createForOfIteratorHelper.js +30 -29
- package/dist/babel_helpers/createForOfIteratorHelperLoose/createForOfIteratorHelperLoose.js +18 -16
- package/dist/babel_helpers/createRawReactElement/createRawReactElement.js +23 -17
- package/dist/babel_helpers/createSuper/createSuper.js +14 -12
- package/dist/babel_helpers/decorate/decorate.js +242 -210
- package/dist/babel_helpers/defaults/defaults.js +6 -6
- package/dist/babel_helpers/defineAccessor/defineAccessor.js +1 -4
- package/dist/babel_helpers/defineEnumerableProperties/defineEnumerableProperties.js +12 -12
- package/dist/babel_helpers/defineProperty/defineProperty.js +7 -6
- package/dist/babel_helpers/extends/extends.js +5 -4
- package/dist/babel_helpers/get/get.js +2 -1
- package/dist/babel_helpers/getPrototypeOf/getPrototypeOf.js +4 -3
- package/dist/babel_helpers/inherits/inherits.js +3 -4
- package/dist/babel_helpers/inheritsLoose/inheritsLoose.js +6 -5
- package/dist/babel_helpers/initializerDefineProperty/initializerDefineProperty.js +4 -4
- package/dist/babel_helpers/initializerWarningHelper/initializerWarningHelper.js +5 -2
- package/dist/babel_helpers/instanceof/instanceof.js +3 -3
- package/dist/babel_helpers/interopRequireDefault/interopRequireDefault.js +2 -4
- package/dist/babel_helpers/interopRequireWildcard/interopRequireWildcard.js +19 -21
- package/dist/babel_helpers/isNativeFunction/isNativeFunction.js +2 -2
- package/dist/babel_helpers/isNativeReflectConstruct/isNativeReflectConstruct.js +7 -7
- package/dist/babel_helpers/iterableToArray/iterableToArray.js +6 -2
- package/dist/babel_helpers/iterableToArrayLimit/iterableToArrayLimit.js +6 -1
- package/dist/babel_helpers/iterableToArrayLimitLoose/iterableToArrayLimitLoose.js +6 -2
- package/dist/babel_helpers/jsx/jsx.js +14 -7
- package/dist/babel_helpers/maybeArrayLike/maybeArrayLike.js +6 -5
- package/dist/babel_helpers/newArrowCheck/newArrowCheck.js +2 -2
- package/dist/babel_helpers/nonIterableRest/nonIterableRest.js +5 -3
- package/dist/babel_helpers/nonIterableSpread/nonIterableSpread.js +5 -3
- package/dist/babel_helpers/objectDestructuringEmpty/objectDestructuringEmpty.js +2 -2
- package/dist/babel_helpers/objectSpread/objectSpread.js +15 -12
- package/dist/babel_helpers/objectSpread2/objectSpread2.js +7 -2
- package/dist/babel_helpers/objectWithoutProperties/objectWithoutProperties.js +15 -13
- package/dist/babel_helpers/objectWithoutPropertiesLoose/objectWithoutPropertiesLoose.js +11 -11
- package/dist/babel_helpers/possibleConstructorReturn/possibleConstructorReturn.js +7 -6
- package/dist/babel_helpers/readOnlyError/readOnlyError.js +2 -2
- package/dist/babel_helpers/regeneratorRuntime/regeneratorRuntime.js +124 -73
- package/dist/babel_helpers/set/set.js +23 -20
- package/dist/babel_helpers/setPrototypeOf/setPrototypeOf.js +6 -5
- package/dist/babel_helpers/skipFirstGeneratorNext/skipFirstGeneratorNext.js +5 -5
- package/dist/babel_helpers/slicedToArray/slicedToArray.js +10 -5
- package/dist/babel_helpers/slicedToArrayLoose/slicedToArrayLoose.js +12 -6
- package/dist/babel_helpers/superPropBase/superPropBase.js +6 -5
- package/dist/babel_helpers/taggedTemplateLiteral/taggedTemplateLiteral.js +7 -7
- package/dist/babel_helpers/taggedTemplateLiteralLoose/taggedTemplateLiteralLoose.js +4 -4
- package/dist/babel_helpers/tdz/tdz.js +2 -2
- package/dist/babel_helpers/temporalRef/temporalRef.js +5 -4
- package/dist/babel_helpers/temporalUndefined/temporalUndefined.js +1 -1
- package/dist/babel_helpers/toArray/toArray.js +10 -5
- package/dist/babel_helpers/toConsumableArray/toConsumableArray.js +10 -5
- package/dist/babel_helpers/toPrimitive/toPrimitive.js +7 -7
- package/dist/babel_helpers/toPropertyKey/toPropertyKey.js +5 -4
- package/dist/babel_helpers/typeof/typeof.js +14 -5
- package/dist/babel_helpers/unsupportedIterableToArray/unsupportedIterableToArray.js +10 -8
- package/dist/babel_helpers/wrapAsyncGenerator/wrapAsyncGenerator.js +5 -4
- package/dist/babel_helpers/wrapNativeSuper/wrapNativeSuper.js +17 -15
- package/dist/babel_helpers/wrapRegExp/wrapRegExp.js +19 -8
- package/dist/babel_helpers/writeOnlyError/writeOnlyError.js +2 -2
- package/dist/js/autoreload.js +148 -133
- package/dist/js/import_meta_hot.js +19 -13
- package/dist/js/inline_content.js +1 -3
- package/dist/js/new_stylesheet.js +119 -60
- package/dist/js/regenerator_runtime.js +204 -102
- package/dist/js/ribbon.js +11 -6
- package/dist/js/server_events_client.js +122 -98
- package/dist/js/ws.js +968 -265
- package/dist/jsenv_core.js +8513 -6162
- package/package.json +9 -9
- package/src/build/build.js +497 -486
- package/src/build/version_mappings_injection.js +21 -44
- package/src/kitchen/errors.js +2 -2
- package/src/kitchen/fetched_content_compliance.js +6 -2
- package/src/kitchen/kitchen.js +285 -80
- package/src/kitchen/prepend_content.js +135 -0
- package/src/kitchen/url_graph/url_graph_visitor.js +99 -0
- package/src/kitchen/url_graph/url_info_transformations.js +140 -21
- package/src/kitchen/url_graph.js +59 -29
- package/src/plugins/autoreload/jsenv_plugin_hmr.js +1 -2
- package/src/plugins/import_meta_hot/jsenv_plugin_import_meta_hot.js +2 -2
- package/src/plugins/importmap/jsenv_plugin_importmap.js +2 -2
- package/src/plugins/inlining/jsenv_plugin_inlining_as_data_url.js +1 -1
- package/src/plugins/reference_analysis/html/jsenv_plugin_html_reference_analysis.js +44 -23
- package/src/plugins/reference_analysis/js/jsenv_plugin_js_reference_analysis.js +2 -1
- package/dist/js/global_this_js_classic.js +0 -24
- package/dist/js/global_this_js_module.js +0 -20
- package/src/build/graph_utils.js +0 -34
|
@@ -4,68 +4,74 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
const urlHotMetas = {};
|
|
7
|
-
|
|
7
|
+
|
|
8
|
+
const createImportMetaHot = (importMetaUrl) => {
|
|
8
9
|
const data = {};
|
|
9
10
|
const url = asUrlWithoutHmrQuery(importMetaUrl);
|
|
11
|
+
|
|
10
12
|
return {
|
|
11
13
|
data,
|
|
12
14
|
accept: (firstArg, secondArg) => {
|
|
13
15
|
if (!firstArg) {
|
|
14
16
|
addUrlMeta(url, {
|
|
15
17
|
dependencies: [url],
|
|
16
|
-
acceptCallback: () => {}
|
|
18
|
+
acceptCallback: () => {},
|
|
17
19
|
});
|
|
18
20
|
return;
|
|
19
21
|
}
|
|
20
22
|
if (typeof firstArg === "function") {
|
|
21
23
|
addUrlMeta(url, {
|
|
22
24
|
dependencies: [url],
|
|
23
|
-
acceptCallback: firstArg
|
|
25
|
+
acceptCallback: firstArg,
|
|
24
26
|
});
|
|
25
27
|
return;
|
|
26
28
|
}
|
|
27
29
|
if (typeof firstArg === "string") {
|
|
28
30
|
addUrlMeta(url, {
|
|
29
31
|
dependencies: [firstArg],
|
|
30
|
-
acceptCallback: secondArg
|
|
32
|
+
acceptCallback: secondArg,
|
|
31
33
|
});
|
|
32
34
|
return;
|
|
33
35
|
}
|
|
34
36
|
if (Array.isArray(firstArg)) {
|
|
35
37
|
addUrlMeta(url, {
|
|
36
38
|
dependencies: firstArg,
|
|
37
|
-
acceptCallback: secondArg
|
|
39
|
+
acceptCallback: secondArg,
|
|
38
40
|
});
|
|
39
41
|
return;
|
|
40
42
|
}
|
|
41
|
-
throw new Error(
|
|
43
|
+
throw new Error(
|
|
44
|
+
`invalid call to import.meta.hot.accept(), received ${firstArg}`,
|
|
45
|
+
);
|
|
42
46
|
},
|
|
43
|
-
dispose: callback => {
|
|
47
|
+
dispose: (callback) => {
|
|
44
48
|
addUrlMeta(url, {
|
|
45
49
|
disposeCallback: () => {
|
|
46
50
|
return callback(data);
|
|
47
|
-
}
|
|
51
|
+
},
|
|
48
52
|
});
|
|
49
53
|
},
|
|
50
54
|
decline: () => {
|
|
51
55
|
addUrlMeta(url, {
|
|
52
|
-
declined: true
|
|
56
|
+
declined: true,
|
|
53
57
|
});
|
|
54
58
|
},
|
|
55
59
|
invalidate: () => {
|
|
56
60
|
addUrlMeta(url, {
|
|
57
|
-
invalidated: true
|
|
61
|
+
invalidated: true,
|
|
58
62
|
});
|
|
59
|
-
}
|
|
63
|
+
},
|
|
60
64
|
};
|
|
61
65
|
};
|
|
66
|
+
|
|
62
67
|
const addUrlMeta = (url, meta) => {
|
|
63
68
|
urlHotMetas[url] = {
|
|
64
69
|
...urlHotMetas[url],
|
|
65
|
-
...meta
|
|
70
|
+
...meta,
|
|
66
71
|
};
|
|
67
72
|
};
|
|
68
|
-
|
|
73
|
+
|
|
74
|
+
const asUrlWithoutHmrQuery = (url) => {
|
|
69
75
|
const urlObject = new URL(url);
|
|
70
76
|
if (urlObject.searchParams.has("hmr")) {
|
|
71
77
|
urlObject.searchParams.delete("hmr");
|
|
@@ -11,9 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
const globalObject = typeof self === "object" ? self : process;
|
|
14
|
-
globalObject.__InlineContent__ = function (content, {
|
|
15
|
-
type = "text/plain"
|
|
16
|
-
}) {
|
|
14
|
+
globalObject.__InlineContent__ = function (content, { type = "text/plain" }) {
|
|
17
15
|
this.text = content;
|
|
18
16
|
this.type = type;
|
|
19
17
|
};
|
|
@@ -7,22 +7,28 @@
|
|
|
7
7
|
if (typeof document === "undefined" || "adoptedStyleSheets" in document) {
|
|
8
8
|
return;
|
|
9
9
|
}
|
|
10
|
+
|
|
10
11
|
var hasShadyCss = "ShadyCSS" in window && !ShadyCSS.nativeShadow;
|
|
11
12
|
var bootstrapper = document.implementation.createHTMLDocument("");
|
|
12
13
|
var closedShadowRootRegistry = new WeakMap();
|
|
13
14
|
var _DOMException = typeof DOMException === "object" ? Error : DOMException;
|
|
14
15
|
var defineProperty = Object.defineProperty;
|
|
15
16
|
var forEach = Array.prototype.forEach;
|
|
17
|
+
|
|
16
18
|
var importPattern = /@import.+?;?$/gm;
|
|
17
19
|
function rejectImports(contents) {
|
|
18
20
|
var _contents = contents.replace(importPattern, "");
|
|
19
21
|
if (_contents !== contents) {
|
|
20
|
-
console.warn(
|
|
22
|
+
console.warn(
|
|
23
|
+
"@import rules are not allowed here. See https://github.com/WICG/construct-stylesheets/issues/119#issuecomment-588352418",
|
|
24
|
+
);
|
|
21
25
|
}
|
|
22
26
|
return _contents.trim();
|
|
23
27
|
}
|
|
24
28
|
function isElementConnected(element) {
|
|
25
|
-
return "isConnected" in element
|
|
29
|
+
return "isConnected" in element
|
|
30
|
+
? element.isConnected
|
|
31
|
+
: document.contains(element);
|
|
26
32
|
}
|
|
27
33
|
function unique(arr) {
|
|
28
34
|
return arr.filter(function (value, index) {
|
|
@@ -40,20 +46,37 @@
|
|
|
40
46
|
function getShadowRoot(element) {
|
|
41
47
|
return element.shadowRoot || closedShadowRootRegistry.get(element);
|
|
42
48
|
}
|
|
43
|
-
|
|
49
|
+
|
|
50
|
+
var cssStyleSheetMethods = [
|
|
51
|
+
"addRule",
|
|
52
|
+
"deleteRule",
|
|
53
|
+
"insertRule",
|
|
54
|
+
"removeRule",
|
|
55
|
+
];
|
|
44
56
|
var NonConstructedStyleSheet = CSSStyleSheet;
|
|
45
57
|
var nonConstructedProto = NonConstructedStyleSheet.prototype;
|
|
46
58
|
nonConstructedProto.replace = function () {
|
|
47
|
-
return Promise.reject(
|
|
59
|
+
return Promise.reject(
|
|
60
|
+
new _DOMException(
|
|
61
|
+
"Can't call replace on non-constructed CSSStyleSheets.",
|
|
62
|
+
),
|
|
63
|
+
);
|
|
48
64
|
};
|
|
49
65
|
nonConstructedProto.replaceSync = function () {
|
|
50
|
-
throw new _DOMException(
|
|
66
|
+
throw new _DOMException(
|
|
67
|
+
"Failed to execute 'replaceSync' on 'CSSStyleSheet': Can't call replaceSync on non-constructed CSSStyleSheets.",
|
|
68
|
+
);
|
|
51
69
|
};
|
|
52
70
|
function isCSSStyleSheetInstance(instance) {
|
|
53
|
-
return typeof instance === "object"
|
|
71
|
+
return typeof instance === "object"
|
|
72
|
+
? proto$1.isPrototypeOf(instance) ||
|
|
73
|
+
nonConstructedProto.isPrototypeOf(instance)
|
|
74
|
+
: false;
|
|
54
75
|
}
|
|
55
76
|
function isNonConstructedStyleSheetInstance(instance) {
|
|
56
|
-
return typeof instance === "object"
|
|
77
|
+
return typeof instance === "object"
|
|
78
|
+
? nonConstructedProto.isPrototypeOf(instance)
|
|
79
|
+
: false;
|
|
57
80
|
}
|
|
58
81
|
var $basicStyleElement = new WeakMap();
|
|
59
82
|
var $locations = new WeakMap();
|
|
@@ -70,9 +93,12 @@
|
|
|
70
93
|
}
|
|
71
94
|
function removeAdopterLocation(sheet, location) {
|
|
72
95
|
$adoptersByLocation.get(sheet).delete(location);
|
|
73
|
-
$locations.set(
|
|
74
|
-
|
|
75
|
-
|
|
96
|
+
$locations.set(
|
|
97
|
+
sheet,
|
|
98
|
+
$locations.get(sheet).filter(function (_location) {
|
|
99
|
+
return _location !== location;
|
|
100
|
+
}),
|
|
101
|
+
);
|
|
76
102
|
}
|
|
77
103
|
function restyleAdopter(sheet, adopter) {
|
|
78
104
|
requestAnimationFrame(function () {
|
|
@@ -124,7 +150,7 @@
|
|
|
124
150
|
get: function cssRules() {
|
|
125
151
|
checkInvocationCorrectness(this);
|
|
126
152
|
return $basicStyleElement.get(this).sheet.cssRules;
|
|
127
|
-
}
|
|
153
|
+
},
|
|
128
154
|
});
|
|
129
155
|
defineProperty(proto$1, "media", {
|
|
130
156
|
configurable: true,
|
|
@@ -132,17 +158,14 @@
|
|
|
132
158
|
get: function media() {
|
|
133
159
|
checkInvocationCorrectness(this);
|
|
134
160
|
return $basicStyleElement.get(this).sheet.media;
|
|
135
|
-
}
|
|
161
|
+
},
|
|
136
162
|
});
|
|
137
163
|
cssStyleSheetMethods.forEach(function (method) {
|
|
138
164
|
proto$1[method] = function () {
|
|
139
165
|
var self = this;
|
|
140
166
|
checkInvocationCorrectness(self);
|
|
141
167
|
var args = arguments;
|
|
142
|
-
$appliedMethods.get(self).push({
|
|
143
|
-
method: method,
|
|
144
|
-
args: args
|
|
145
|
-
});
|
|
168
|
+
$appliedMethods.get(self).push({ method: method, args: args });
|
|
146
169
|
$locations.get(self).forEach(function (location) {
|
|
147
170
|
if (location.isConnected()) {
|
|
148
171
|
var sheet = getAdopterByLocation(self, location).sheet;
|
|
@@ -155,11 +178,12 @@
|
|
|
155
178
|
});
|
|
156
179
|
defineProperty(ConstructedStyleSheet, Symbol.hasInstance, {
|
|
157
180
|
configurable: true,
|
|
158
|
-
value: isCSSStyleSheetInstance
|
|
181
|
+
value: isCSSStyleSheetInstance,
|
|
159
182
|
});
|
|
183
|
+
|
|
160
184
|
var defaultObserverOptions = {
|
|
161
185
|
childList: true,
|
|
162
|
-
subtree: true
|
|
186
|
+
subtree: true,
|
|
163
187
|
};
|
|
164
188
|
var locations = new WeakMap();
|
|
165
189
|
function getAssociatedLocation(element) {
|
|
@@ -179,14 +203,22 @@
|
|
|
179
203
|
},
|
|
180
204
|
set: function (sheets) {
|
|
181
205
|
getAssociatedLocation(this).update(sheets);
|
|
182
|
-
}
|
|
206
|
+
},
|
|
183
207
|
});
|
|
184
208
|
}
|
|
185
209
|
function traverseWebComponents(node, callback) {
|
|
186
|
-
var iter = document.createNodeIterator(
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
210
|
+
var iter = document.createNodeIterator(
|
|
211
|
+
node,
|
|
212
|
+
NodeFilter.SHOW_ELEMENT,
|
|
213
|
+
function (foundNode) {
|
|
214
|
+
return getShadowRoot(foundNode)
|
|
215
|
+
? NodeFilter.FILTER_ACCEPT
|
|
216
|
+
: NodeFilter.FILTER_REJECT;
|
|
217
|
+
},
|
|
218
|
+
null,
|
|
219
|
+
false,
|
|
220
|
+
);
|
|
221
|
+
for (var next = void 0; (next = iter.nextNode()); ) {
|
|
190
222
|
callback(getShadowRoot(next));
|
|
191
223
|
}
|
|
192
224
|
}
|
|
@@ -194,9 +226,12 @@
|
|
|
194
226
|
var $uniqueSheets = new WeakMap();
|
|
195
227
|
var $observer = new WeakMap();
|
|
196
228
|
function isExistingAdopter(self, element) {
|
|
197
|
-
return
|
|
198
|
-
|
|
199
|
-
|
|
229
|
+
return (
|
|
230
|
+
element instanceof HTMLStyleElement &&
|
|
231
|
+
$uniqueSheets.get(self).some(function (sheet) {
|
|
232
|
+
return getAdopterByLocation(sheet, self);
|
|
233
|
+
})
|
|
234
|
+
);
|
|
200
235
|
}
|
|
201
236
|
function getAdopterContainer(self) {
|
|
202
237
|
var element = $element.get(self);
|
|
@@ -209,7 +244,9 @@
|
|
|
209
244
|
var container = getAdopterContainer(self);
|
|
210
245
|
observer.disconnect();
|
|
211
246
|
sheets.forEach(function (sheet) {
|
|
212
|
-
styleList.appendChild(
|
|
247
|
+
styleList.appendChild(
|
|
248
|
+
getAdopterByLocation(sheet, self) || addAdopterLocation(sheet, self),
|
|
249
|
+
);
|
|
213
250
|
});
|
|
214
251
|
container.insertBefore(styleList, null);
|
|
215
252
|
observer.observe(container, defaultObserverOptions);
|
|
@@ -222,42 +259,47 @@
|
|
|
222
259
|
self.sheets = [];
|
|
223
260
|
$element.set(self, element);
|
|
224
261
|
$uniqueSheets.set(self, []);
|
|
225
|
-
$observer.set(
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
if (!hasShadyCss) {
|
|
232
|
-
forEach.call(mutation.addedNodes, function (node) {
|
|
233
|
-
if (!(node instanceof Element)) {
|
|
234
|
-
return;
|
|
235
|
-
}
|
|
236
|
-
traverseWebComponents(node, function (root) {
|
|
237
|
-
getAssociatedLocation(root).connect();
|
|
238
|
-
});
|
|
239
|
-
});
|
|
262
|
+
$observer.set(
|
|
263
|
+
self,
|
|
264
|
+
new MutationObserver(function (mutations, observer) {
|
|
265
|
+
if (!document) {
|
|
266
|
+
observer.disconnect();
|
|
267
|
+
return;
|
|
240
268
|
}
|
|
241
|
-
forEach
|
|
242
|
-
if (!(node instanceof Element)) {
|
|
243
|
-
return;
|
|
244
|
-
}
|
|
245
|
-
if (isExistingAdopter(self, node)) {
|
|
246
|
-
adopt(self);
|
|
247
|
-
}
|
|
269
|
+
mutations.forEach(function (mutation) {
|
|
248
270
|
if (!hasShadyCss) {
|
|
249
|
-
|
|
250
|
-
|
|
271
|
+
forEach.call(mutation.addedNodes, function (node) {
|
|
272
|
+
if (!(node instanceof Element)) {
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
traverseWebComponents(node, function (root) {
|
|
276
|
+
getAssociatedLocation(root).connect();
|
|
277
|
+
});
|
|
251
278
|
});
|
|
252
279
|
}
|
|
280
|
+
forEach.call(mutation.removedNodes, function (node) {
|
|
281
|
+
if (!(node instanceof Element)) {
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
if (isExistingAdopter(self, node)) {
|
|
285
|
+
adopt(self);
|
|
286
|
+
}
|
|
287
|
+
if (!hasShadyCss) {
|
|
288
|
+
traverseWebComponents(node, function (root) {
|
|
289
|
+
getAssociatedLocation(root).disconnect();
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
});
|
|
253
293
|
});
|
|
254
|
-
})
|
|
255
|
-
|
|
294
|
+
}),
|
|
295
|
+
);
|
|
256
296
|
}
|
|
257
297
|
Location.prototype = {
|
|
258
298
|
isConnected: function () {
|
|
259
299
|
var element = $element.get(this);
|
|
260
|
-
return element instanceof Document
|
|
300
|
+
return element instanceof Document
|
|
301
|
+
? element.readyState !== "loading"
|
|
302
|
+
: isElementConnected(element.host);
|
|
261
303
|
},
|
|
262
304
|
connect: function () {
|
|
263
305
|
var container = getAdopterContainer(this);
|
|
@@ -274,15 +316,28 @@
|
|
|
274
316
|
},
|
|
275
317
|
update: function (sheets) {
|
|
276
318
|
var self = this;
|
|
277
|
-
var locationType =
|
|
319
|
+
var locationType =
|
|
320
|
+
$element.get(self) === document ? "Document" : "ShadowRoot";
|
|
278
321
|
if (!Array.isArray(sheets)) {
|
|
279
|
-
throw new TypeError(
|
|
322
|
+
throw new TypeError(
|
|
323
|
+
"Failed to set the 'adoptedStyleSheets' property on " +
|
|
324
|
+
locationType +
|
|
325
|
+
": Iterator getter is not callable.",
|
|
326
|
+
);
|
|
280
327
|
}
|
|
281
328
|
if (!sheets.every(isCSSStyleSheetInstance)) {
|
|
282
|
-
throw new TypeError(
|
|
329
|
+
throw new TypeError(
|
|
330
|
+
"Failed to set the 'adoptedStyleSheets' property on " +
|
|
331
|
+
locationType +
|
|
332
|
+
": Failed to convert value to 'CSSStyleSheet'",
|
|
333
|
+
);
|
|
283
334
|
}
|
|
284
335
|
if (sheets.some(isNonConstructedStyleSheetInstance)) {
|
|
285
|
-
throw new TypeError(
|
|
336
|
+
throw new TypeError(
|
|
337
|
+
"Failed to set the 'adoptedStyleSheets' property on " +
|
|
338
|
+
locationType +
|
|
339
|
+
": Can't adopt non-constructed stylesheets",
|
|
340
|
+
);
|
|
286
341
|
}
|
|
287
342
|
self.sheets = sheets;
|
|
288
343
|
var oldUniqueSheets = $uniqueSheets.get(self);
|
|
@@ -296,8 +351,9 @@
|
|
|
296
351
|
if (self.isConnected() && uniqueSheets.length > 0) {
|
|
297
352
|
adopt(self);
|
|
298
353
|
}
|
|
299
|
-
}
|
|
354
|
+
},
|
|
300
355
|
};
|
|
356
|
+
|
|
301
357
|
window.CSSStyleSheet = ConstructedStyleSheet;
|
|
302
358
|
attachAdoptedStyleSheetProperty(Document);
|
|
303
359
|
if ("ShadowRoot" in window) {
|
|
@@ -316,6 +372,9 @@
|
|
|
316
372
|
if (documentLocation.isConnected()) {
|
|
317
373
|
documentLocation.connect();
|
|
318
374
|
} else {
|
|
319
|
-
document.addEventListener(
|
|
375
|
+
document.addEventListener(
|
|
376
|
+
"DOMContentLoaded",
|
|
377
|
+
documentLocation.connect.bind(documentLocation),
|
|
378
|
+
);
|
|
320
379
|
}
|
|
321
380
|
})();
|