@lwc/synthetic-shadow 2.21.1 → 2.23.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/dist/synthetic-shadow.js +30 -27
- package/package.json +3 -3
package/dist/synthetic-shadow.js
CHANGED
@@ -148,7 +148,7 @@ const KEY__SYNTHETIC_MODE = '$$lwc-synthetic-mode';
|
|
148
148
|
// We use this to detect symbol support in order to avoid the expensive symbol polyfill. Note that
|
149
149
|
// we can't use typeof since it will fail when transpiling.
|
150
150
|
const hasNativeSymbolSupport = /*@__PURE__*/ (() => Symbol('x').toString() === 'Symbol(x)')();
|
151
|
-
/** version: 2.
|
151
|
+
/** version: 2.23.1 */
|
152
152
|
|
153
153
|
/*
|
154
154
|
* Copyright (c) 2018, salesforce.com, inc.
|
@@ -299,7 +299,7 @@ const elementsFromPoint = hasOwnProperty.call(Document.prototype, 'elementsFromP
|
|
299
299
|
// defaultView can be null when a document has no browsing context. For example, the owner document
|
300
300
|
// of a node in a template doesn't have a default view: https://jsfiddle.net/hv9z0q5a/
|
301
301
|
const defaultViewGetter = getOwnPropertyDescriptor(Document.prototype, 'defaultView').get;
|
302
|
-
const { createComment,
|
302
|
+
const { createComment, querySelectorAll, getElementById, getElementsByClassName, getElementsByTagName, getElementsByTagNameNS, } = Document.prototype;
|
303
303
|
// In Firefox v57 and lower, getElementsByName is defined on HTMLDocument.prototype
|
304
304
|
// In all other browsers have the method on Document.prototype
|
305
305
|
const { getElementsByName } = HTMLDocument.prototype;
|
@@ -1123,8 +1123,8 @@ function createStaticHTMLCollection(items) {
|
|
1123
1123
|
if (!_globalThis.lwcRuntimeFlags) {
|
1124
1124
|
Object.defineProperty(_globalThis, 'lwcRuntimeFlags', { value: create(null) });
|
1125
1125
|
}
|
1126
|
-
const
|
1127
|
-
/** version: 2.
|
1126
|
+
const lwcRuntimeFlags = _globalThis.lwcRuntimeFlags;
|
1127
|
+
/** version: 2.23.1 */
|
1128
1128
|
|
1129
1129
|
/*
|
1130
1130
|
* Copyright (c) 2018, salesforce.com, inc.
|
@@ -1375,7 +1375,7 @@ defineProperties(_Node.prototype, {
|
|
1375
1375
|
},
|
1376
1376
|
textContent: {
|
1377
1377
|
get() {
|
1378
|
-
if (!
|
1378
|
+
if (!lwcRuntimeFlags.ENABLE_NODE_PATCH) {
|
1379
1379
|
if (isNodeShadowed(this) || isSyntheticShadowHost(this)) {
|
1380
1380
|
return textContentGetterPatched.call(this);
|
1381
1381
|
}
|
@@ -1482,7 +1482,7 @@ defineProperties(_Node.prototype, {
|
|
1482
1482
|
return true;
|
1483
1483
|
}
|
1484
1484
|
|
1485
|
-
if (!
|
1485
|
+
if (!lwcRuntimeFlags.ENABLE_NODE_PATCH) {
|
1486
1486
|
if (otherNode == null) {
|
1487
1487
|
return false;
|
1488
1488
|
}
|
@@ -1508,7 +1508,7 @@ defineProperties(_Node.prototype, {
|
|
1508
1508
|
},
|
1509
1509
|
cloneNode: {
|
1510
1510
|
value(deep) {
|
1511
|
-
if (!
|
1511
|
+
if (!lwcRuntimeFlags.ENABLE_NODE_PATCH) {
|
1512
1512
|
if (isNodeShadowed(this) || isSyntheticShadowHost(this)) {
|
1513
1513
|
return cloneNodePatched.call(this, deep);
|
1514
1514
|
}
|
@@ -3808,7 +3808,7 @@ function lastElementChildGetterPatched() {
|
|
3808
3808
|
defineProperties(Element.prototype, {
|
3809
3809
|
innerHTML: {
|
3810
3810
|
get() {
|
3811
|
-
if (!
|
3811
|
+
if (!lwcRuntimeFlags.ENABLE_ELEMENT_PATCH) {
|
3812
3812
|
if (isNodeShadowed(this) || isSyntheticShadowHost(this)) {
|
3813
3813
|
return innerHTMLGetterPatched.call(this);
|
3814
3814
|
}
|
@@ -3833,7 +3833,7 @@ defineProperties(Element.prototype, {
|
|
3833
3833
|
},
|
3834
3834
|
outerHTML: {
|
3835
3835
|
get() {
|
3836
|
-
if (!
|
3836
|
+
if (!lwcRuntimeFlags.ENABLE_ELEMENT_PATCH) {
|
3837
3837
|
if (isNodeShadowed(this) || isSyntheticShadowHost(this)) {
|
3838
3838
|
return outerHTMLGetterPatched.call(this);
|
3839
3839
|
}
|
@@ -3961,7 +3961,7 @@ function querySelectorPatched() {
|
|
3961
3961
|
const elm = ArrayFind.call(nodeList, elm => getNodeNearestOwnerKey(elm) === ownerKey);
|
3962
3962
|
return isUndefined(elm) ? null : elm;
|
3963
3963
|
} else {
|
3964
|
-
if (!
|
3964
|
+
if (!lwcRuntimeFlags.ENABLE_NODE_LIST_PATCH) {
|
3965
3965
|
// `this` is a manually inserted element inside a shadowRoot, return the first element.
|
3966
3966
|
return nodeList.length === 0 ? null : nodeList[0];
|
3967
3967
|
} // Element is inside a shadow but we dont know which one. Use the
|
@@ -3973,7 +3973,7 @@ function querySelectorPatched() {
|
|
3973
3973
|
return isUndefined(elm) ? null : elm;
|
3974
3974
|
}
|
3975
3975
|
} else {
|
3976
|
-
if (!
|
3976
|
+
if (!lwcRuntimeFlags.ENABLE_NODE_LIST_PATCH) {
|
3977
3977
|
if (!(this instanceof HTMLBodyElement)) {
|
3978
3978
|
const elm = nodeList[0];
|
3979
3979
|
return isUndefined(elm) ? null : elm;
|
@@ -4056,7 +4056,7 @@ defineProperties(Element.prototype, {
|
|
4056
4056
|
value() {
|
4057
4057
|
const nodeList = arrayFromCollection(querySelectorAll$1.apply(this, ArraySlice.call(arguments)));
|
4058
4058
|
|
4059
|
-
if (!
|
4059
|
+
if (!lwcRuntimeFlags.ENABLE_NODE_LIST_PATCH) {
|
4060
4060
|
const filteredResults = getFilteredArrayOfNodes(this, nodeList, 0
|
4061
4061
|
/* ShadowDomSemantic.Disabled */
|
4062
4062
|
);
|
@@ -4080,7 +4080,7 @@ if (process.env.NODE_ENV !== 'test') {
|
|
4080
4080
|
value() {
|
4081
4081
|
const elements = arrayFromCollection(getElementsByClassName$1.apply(this, ArraySlice.call(arguments)));
|
4082
4082
|
|
4083
|
-
if (!
|
4083
|
+
if (!lwcRuntimeFlags.ENABLE_HTML_COLLECTIONS_PATCH) {
|
4084
4084
|
return createStaticHTMLCollection(getNonPatchedFilteredArrayOfNodes(this, elements));
|
4085
4085
|
}
|
4086
4086
|
|
@@ -4098,7 +4098,7 @@ if (process.env.NODE_ENV !== 'test') {
|
|
4098
4098
|
value() {
|
4099
4099
|
const elements = arrayFromCollection(getElementsByTagName$1.apply(this, ArraySlice.call(arguments)));
|
4100
4100
|
|
4101
|
-
if (!
|
4101
|
+
if (!lwcRuntimeFlags.ENABLE_HTML_COLLECTIONS_PATCH) {
|
4102
4102
|
return createStaticHTMLCollection(getNonPatchedFilteredArrayOfNodes(this, elements));
|
4103
4103
|
}
|
4104
4104
|
|
@@ -4116,7 +4116,7 @@ if (process.env.NODE_ENV !== 'test') {
|
|
4116
4116
|
value() {
|
4117
4117
|
const elements = arrayFromCollection(getElementsByTagNameNS$1.apply(this, ArraySlice.call(arguments)));
|
4118
4118
|
|
4119
|
-
if (!
|
4119
|
+
if (!lwcRuntimeFlags.ENABLE_HTML_COLLECTIONS_PATCH) {
|
4120
4120
|
return createStaticHTMLCollection(getNonPatchedFilteredArrayOfNodes(this, elements));
|
4121
4121
|
}
|
4122
4122
|
|
@@ -4848,11 +4848,11 @@ defineProperties(HTMLElement.prototype, {
|
|
4848
4848
|
if (innerTextGetter !== null && innerTextSetter !== null) {
|
4849
4849
|
defineProperty(HTMLElement.prototype, 'innerText', {
|
4850
4850
|
get() {
|
4851
|
-
if (!
|
4851
|
+
if (!lwcRuntimeFlags.ENABLE_INNER_OUTER_TEXT_PATCH) {
|
4852
4852
|
return innerTextGetter.call(this);
|
4853
4853
|
}
|
4854
4854
|
|
4855
|
-
if (!
|
4855
|
+
if (!lwcRuntimeFlags.ENABLE_ELEMENT_PATCH) {
|
4856
4856
|
if (isNodeShadowed(this) || isSyntheticShadowHost(this)) {
|
4857
4857
|
return getInnerText(this);
|
4858
4858
|
}
|
@@ -4884,11 +4884,11 @@ if (outerTextGetter !== null && outerTextSetter !== null) {
|
|
4884
4884
|
// As a setter, it removes the current node and replaces it with the given text.
|
4885
4885
|
defineProperty(HTMLElement.prototype, 'outerText', {
|
4886
4886
|
get() {
|
4887
|
-
if (!
|
4887
|
+
if (!lwcRuntimeFlags.ENABLE_INNER_OUTER_TEXT_PATCH) {
|
4888
4888
|
return outerTextGetter.call(this);
|
4889
4889
|
}
|
4890
4890
|
|
4891
|
-
if (!
|
4891
|
+
if (!lwcRuntimeFlags.ENABLE_ELEMENT_PATCH) {
|
4892
4892
|
if (isNodeShadowed(this) || isSyntheticShadowHost(this)) {
|
4893
4893
|
return getInnerText(this);
|
4894
4894
|
}
|
@@ -4953,16 +4953,19 @@ defineProperty(Element.prototype, KEY__SHADOW_TOKEN, {
|
|
4953
4953
|
},
|
4954
4954
|
configurable: true,
|
4955
4955
|
});
|
4956
|
+
function recursivelySetShadowResolver(node, fn) {
|
4957
|
+
node[KEY__SHADOW_RESOLVER] = fn;
|
4958
|
+
const childNodes = childNodesGetter.call(node);
|
4959
|
+
for (let i = 0, n = childNodes.length; i < n; i++) {
|
4960
|
+
recursivelySetShadowResolver(childNodes[i], fn);
|
4961
|
+
}
|
4962
|
+
}
|
4956
4963
|
defineProperty(Element.prototype, KEY__SHADOW_STATIC, {
|
4957
4964
|
set(v) {
|
4958
4965
|
// Marking an element as static will propagate the shadow resolver to the children.
|
4959
|
-
const fn = this[KEY__SHADOW_RESOLVER];
|
4960
4966
|
if (v) {
|
4961
|
-
const
|
4962
|
-
|
4963
|
-
while ((currentNode = treeWalker.nextNode())) {
|
4964
|
-
currentNode[KEY__SHADOW_RESOLVER] = fn;
|
4965
|
-
}
|
4967
|
+
const fn = this[KEY__SHADOW_RESOLVER];
|
4968
|
+
recursivelySetShadowResolver(this, fn);
|
4966
4969
|
}
|
4967
4970
|
this[KEY__SHADOW_STATIC_PRIVATE] = v;
|
4968
4971
|
},
|
@@ -5099,7 +5102,7 @@ if (process.env.NODE_ENV !== 'production' && typeof __karma__ !== 'undefined') {
|
|
5099
5102
|
window.addEventListener('test-dummy-flag', () => {
|
5100
5103
|
let hasFlag = false;
|
5101
5104
|
|
5102
|
-
if (
|
5105
|
+
if (lwcRuntimeFlags.DUMMY_TEST_FLAG) {
|
5103
5106
|
hasFlag = true;
|
5104
5107
|
}
|
5105
5108
|
|
@@ -5111,4 +5114,4 @@ if (process.env.NODE_ENV !== 'production' && typeof __karma__ !== 'undefined') {
|
|
5111
5114
|
}));
|
5112
5115
|
});
|
5113
5116
|
}
|
5114
|
-
/** version: 2.
|
5117
|
+
/** version: 2.23.1 */
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@lwc/synthetic-shadow",
|
3
|
-
"version": "2.
|
3
|
+
"version": "2.23.1",
|
4
4
|
"description": "Synthetic Shadow Root for LWC",
|
5
5
|
"homepage": "https://lwc.dev/",
|
6
6
|
"repository": {
|
@@ -37,7 +37,7 @@
|
|
37
37
|
"access": "public"
|
38
38
|
},
|
39
39
|
"devDependencies": {
|
40
|
-
"@lwc/features": "2.
|
41
|
-
"@lwc/shared": "2.
|
40
|
+
"@lwc/features": "2.23.1",
|
41
|
+
"@lwc/shared": "2.23.1"
|
42
42
|
}
|
43
43
|
}
|