@adobe/alloy 2.7.0-beta.0 → 2.8.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/libEs5/components/ActivityCollector/utils.js +1 -1
- package/libEs5/components/Personalization/createCollect.js +1 -1
- package/libEs5/components/Personalization/createOnClickHandler.js +1 -1
- package/libEs5/components/Personalization/createViewCollect.js +1 -1
- package/libEs5/components/Personalization/dom-actions/action.js +25 -25
- package/libEs5/components/Personalization/dom-actions/appendHtml.js +1 -1
- package/libEs5/components/Personalization/dom-actions/dom/index.js +26 -26
- package/libEs5/components/Personalization/dom-actions/dom/selectNodesWithEq.js +1 -1
- package/libEs5/components/Personalization/dom-actions/index.js +4 -4
- package/libEs5/components/Personalization/dom-actions/insertHtmlAfter.js +1 -1
- package/libEs5/components/Personalization/dom-actions/insertHtmlBefore.js +1 -1
- package/libEs5/components/Personalization/dom-actions/prependHtml.js +1 -1
- package/libEs5/components/Personalization/dom-actions/scripts.js +6 -5
- package/libEs5/components/Personalization/dom-actions/setStyles.js +3 -1
- package/libEs5/components/Personalization/event.js +2 -2
- package/libEs5/components/Personalization/flicker/index.js +3 -3
- package/libEs5/components/Personalization/groupDecisions.js +1 -1
- package/libEs5/components/Privacy/computeConsentHash.js +1 -1
- package/libEs5/components/Privacy/createConsentHashStore.js +3 -1
- package/libEs5/components/Privacy/parseConsentCookie.js +1 -1
- package/libEs5/constants/cookieNameKey.js +1 -1
- package/libEs5/constants/httpHeaderNames.js +1 -1
- package/libEs5/constants/httpStatusCode.js +1 -1
- package/libEs5/constants/libraryVersion.js +1 -1
- package/libEs5/constants/shadowSeparator.js +17 -0
- package/libEs5/constants/tagName.js +1 -1
- package/libEs5/core/consent/createConsentStateMachine.js +1 -1
- package/libEs5/core/network/injectSendNetworkRequest.js +2 -2
- package/libEs5/utils/convertTimes.js +1 -1
- package/libEs5/utils/dom/awaitSelector.js +1 -1
- package/libEs5/utils/dom/index.js +21 -5
- package/libEs5/utils/dom/isShadowSelector.js +22 -0
- package/libEs5/utils/dom/querySelectorAll.js +22 -0
- package/libEs5/utils/dom/selectNodes.js +11 -2
- package/libEs5/utils/dom/selectNodesWithShadow.js +74 -0
- package/libEs5/utils/fireReferrerHideableImage.js +1 -1
- package/libEs5/utils/index.js +20 -20
- package/libEs5/utils/isObject.js +1 -1
- package/libEs5/utils/validation/index.js +1 -1
- package/libEs6/components/Personalization/createCollect.js +1 -1
- package/libEs6/components/Personalization/createOnClickHandler.js +1 -1
- package/libEs6/components/Personalization/createViewCollect.js +1 -1
- package/libEs6/components/Personalization/dom-actions/appendHtml.js +1 -1
- package/libEs6/components/Personalization/dom-actions/insertHtmlAfter.js +1 -1
- package/libEs6/components/Personalization/dom-actions/insertHtmlBefore.js +1 -1
- package/libEs6/components/Personalization/dom-actions/prependHtml.js +1 -1
- package/libEs6/components/Personalization/dom-actions/scripts.js +5 -2
- package/libEs6/constants/libraryVersion.js +1 -1
- package/libEs6/constants/shadowSeparator.js +12 -0
- package/libEs6/utils/dom/index.js +3 -1
- package/libEs6/utils/dom/isShadowSelector.js +13 -0
- package/libEs6/utils/dom/querySelectorAll.js +13 -0
- package/libEs6/utils/dom/selectNodes.js +8 -2
- package/libEs6/utils/dom/selectNodesWithShadow.js +66 -0
- package/package.json +10 -9
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.default = void 0;
|
|
4
|
+
|
|
5
|
+
var _shadowSeparator = require("../../constants/shadowSeparator");
|
|
6
|
+
|
|
7
|
+
/*
|
|
8
|
+
Copyright 2022 Adobe. All rights reserved.
|
|
9
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
10
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
11
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
|
|
13
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
14
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
15
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
16
|
+
governing permissions and limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
var _default = function _default(str) {
|
|
19
|
+
return str.indexOf(_shadowSeparator.default) !== -1;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
exports.default = _default;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.default = void 0;
|
|
4
|
+
|
|
5
|
+
var _toArray = require("../toArray");
|
|
6
|
+
|
|
7
|
+
/*
|
|
8
|
+
Copyright 2021 Adobe. All rights reserved.
|
|
9
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
10
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
11
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
|
|
13
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
14
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
15
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
16
|
+
governing permissions and limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
var _default = function _default(context, selector) {
|
|
19
|
+
return (0, _toArray.default)(context.querySelectorAll(selector));
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
exports.default = _default;
|
|
@@ -2,7 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
exports.default = void 0;
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _querySelectorAll = require("./querySelectorAll");
|
|
6
|
+
|
|
7
|
+
var _selectNodesWithShadow = require("./selectNodesWithShadow");
|
|
8
|
+
|
|
9
|
+
var _isShadowSelector = require("./isShadowSelector");
|
|
6
10
|
|
|
7
11
|
/*
|
|
8
12
|
Copyright 2019 Adobe. All rights reserved.
|
|
@@ -24,7 +28,12 @@ governing permissions and limitations under the License.
|
|
|
24
28
|
*/
|
|
25
29
|
var _default = function _default(selector) {
|
|
26
30
|
var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : document;
|
|
27
|
-
|
|
31
|
+
|
|
32
|
+
if (!(0, _isShadowSelector.default)(selector)) {
|
|
33
|
+
return (0, _querySelectorAll.default)(context, selector);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return (0, _selectNodesWithShadow.default)(context, selector);
|
|
28
37
|
};
|
|
29
38
|
|
|
30
39
|
exports.default = _default;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.default = void 0;
|
|
4
|
+
|
|
5
|
+
var _querySelectorAll = require("./querySelectorAll");
|
|
6
|
+
|
|
7
|
+
var _startsWith = require("../startsWith");
|
|
8
|
+
|
|
9
|
+
var _shadowSeparator = require("../../constants/shadowSeparator");
|
|
10
|
+
|
|
11
|
+
/*
|
|
12
|
+
Copyright 2021 Adobe. All rights reserved.
|
|
13
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
14
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
15
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
+
|
|
17
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
18
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
19
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
20
|
+
governing permissions and limitations under the License.
|
|
21
|
+
*/
|
|
22
|
+
var splitWithShadow = function splitWithShadow(selector) {
|
|
23
|
+
return selector.split(_shadowSeparator.default);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
var transformPrefix = function transformPrefix(parent, selector) {
|
|
27
|
+
var result = selector.trim();
|
|
28
|
+
var hasChildCombinatorPrefix = (0, _startsWith.default)(result, ">");
|
|
29
|
+
|
|
30
|
+
if (!hasChildCombinatorPrefix) {
|
|
31
|
+
return result;
|
|
32
|
+
} // IE doesn't support :scope
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
if (window.document.documentMode) {
|
|
36
|
+
return result.substring(1).trim();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
var prefix = parent instanceof Element || parent instanceof HTMLDocument ? ":scope" : ":host"; // see https://bugs.webkit.org/show_bug.cgi?id=233380
|
|
40
|
+
|
|
41
|
+
return prefix + " " + result;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
var _default = function _default(context, selector) {
|
|
45
|
+
// Shadow DOM should be supported
|
|
46
|
+
if (!window.document.documentElement.attachShadow) {
|
|
47
|
+
return (0, _querySelectorAll.default)(context, selector.replace(_shadowSeparator.default, ""));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
var parts = splitWithShadow(selector);
|
|
51
|
+
|
|
52
|
+
if (parts.length < 2) {
|
|
53
|
+
return (0, _querySelectorAll.default)(context, selector);
|
|
54
|
+
} // split the selector into parts separated by :shadow pseudo-selectors
|
|
55
|
+
// find each subselector element based on the previously selected node's shadowRoot
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
var parent = context;
|
|
59
|
+
|
|
60
|
+
for (var i = 0; i < parts.length; i += 1) {
|
|
61
|
+
var part = transformPrefix(parent, parts[i]);
|
|
62
|
+
var partNode = (0, _querySelectorAll.default)(parent, part);
|
|
63
|
+
|
|
64
|
+
if (partNode.length === 0 || !partNode[0] || !partNode[0].shadowRoot) {
|
|
65
|
+
return partNode;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
parent = partNode[0].shadowRoot;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return undefined;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
exports.default = _default;
|
|
@@ -16,7 +16,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
16
16
|
|
|
17
17
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
18
18
|
|
|
19
|
-
function _iterableToArrayLimit(arr, i) { var _i = arr
|
|
19
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
20
20
|
|
|
21
21
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
22
22
|
|
package/libEs5/utils/index.js
CHANGED
|
@@ -36,10 +36,10 @@ Object.defineProperty(exports, "cookieJar", {
|
|
|
36
36
|
return _cookieJar.default;
|
|
37
37
|
}
|
|
38
38
|
});
|
|
39
|
-
Object.defineProperty(exports, "
|
|
39
|
+
Object.defineProperty(exports, "crc32", {
|
|
40
40
|
enumerable: true,
|
|
41
41
|
get: function get() {
|
|
42
|
-
return
|
|
42
|
+
return _crc.default;
|
|
43
43
|
}
|
|
44
44
|
});
|
|
45
45
|
Object.defineProperty(exports, "createCallbackAggregator", {
|
|
@@ -48,28 +48,28 @@ Object.defineProperty(exports, "createCallbackAggregator", {
|
|
|
48
48
|
return _createCallbackAggregator.default;
|
|
49
49
|
}
|
|
50
50
|
});
|
|
51
|
-
Object.defineProperty(exports, "
|
|
51
|
+
Object.defineProperty(exports, "createMerger", {
|
|
52
52
|
enumerable: true,
|
|
53
53
|
get: function get() {
|
|
54
|
-
return
|
|
54
|
+
return _createMerger.default;
|
|
55
55
|
}
|
|
56
56
|
});
|
|
57
|
-
Object.defineProperty(exports, "
|
|
57
|
+
Object.defineProperty(exports, "createTaskQueue", {
|
|
58
58
|
enumerable: true,
|
|
59
59
|
get: function get() {
|
|
60
|
-
return
|
|
60
|
+
return _createTaskQueue.default;
|
|
61
61
|
}
|
|
62
62
|
});
|
|
63
|
-
Object.defineProperty(exports, "
|
|
63
|
+
Object.defineProperty(exports, "deepAssign", {
|
|
64
64
|
enumerable: true,
|
|
65
65
|
get: function get() {
|
|
66
|
-
return
|
|
66
|
+
return _deepAssign.default;
|
|
67
67
|
}
|
|
68
68
|
});
|
|
69
|
-
Object.defineProperty(exports, "
|
|
69
|
+
Object.defineProperty(exports, "defer", {
|
|
70
70
|
enumerable: true,
|
|
71
71
|
get: function get() {
|
|
72
|
-
return
|
|
72
|
+
return _defer.default;
|
|
73
73
|
}
|
|
74
74
|
});
|
|
75
75
|
Object.defineProperty(exports, "endsWith", {
|
|
@@ -180,22 +180,22 @@ Object.defineProperty(exports, "isNamespacedCookieName", {
|
|
|
180
180
|
return _isNamespacedCookieName.default;
|
|
181
181
|
}
|
|
182
182
|
});
|
|
183
|
-
Object.defineProperty(exports, "
|
|
183
|
+
Object.defineProperty(exports, "isNil", {
|
|
184
184
|
enumerable: true,
|
|
185
185
|
get: function get() {
|
|
186
|
-
return
|
|
186
|
+
return _isNil.default;
|
|
187
187
|
}
|
|
188
188
|
});
|
|
189
|
-
Object.defineProperty(exports, "
|
|
189
|
+
Object.defineProperty(exports, "isNonEmptyArray", {
|
|
190
190
|
enumerable: true,
|
|
191
191
|
get: function get() {
|
|
192
|
-
return
|
|
192
|
+
return _isNonEmptyArray.default;
|
|
193
193
|
}
|
|
194
194
|
});
|
|
195
|
-
Object.defineProperty(exports, "
|
|
195
|
+
Object.defineProperty(exports, "isNonEmptyString", {
|
|
196
196
|
enumerable: true,
|
|
197
197
|
get: function get() {
|
|
198
|
-
return
|
|
198
|
+
return _isNonEmptyString.default;
|
|
199
199
|
}
|
|
200
200
|
});
|
|
201
201
|
Object.defineProperty(exports, "isNumber", {
|
|
@@ -282,16 +282,16 @@ Object.defineProperty(exports, "toISOStringLocal", {
|
|
|
282
282
|
return _toISOStringLocal.default;
|
|
283
283
|
}
|
|
284
284
|
});
|
|
285
|
-
Object.defineProperty(exports, "
|
|
285
|
+
Object.defineProperty(exports, "updateErrorMessage", {
|
|
286
286
|
enumerable: true,
|
|
287
287
|
get: function get() {
|
|
288
|
-
return
|
|
288
|
+
return _updateErrorMessage.default;
|
|
289
289
|
}
|
|
290
290
|
});
|
|
291
|
-
Object.defineProperty(exports, "
|
|
291
|
+
Object.defineProperty(exports, "uuid", {
|
|
292
292
|
enumerable: true,
|
|
293
293
|
get: function get() {
|
|
294
|
-
return
|
|
294
|
+
return _uuid.default;
|
|
295
295
|
}
|
|
296
296
|
});
|
|
297
297
|
Object.defineProperty(exports, "validateIdentityMap", {
|
package/libEs5/utils/isObject.js
CHANGED
|
@@ -4,7 +4,7 @@ exports.default = void 0;
|
|
|
4
4
|
|
|
5
5
|
var _isNil = require("./isNil");
|
|
6
6
|
|
|
7
|
-
function _typeof(obj) { "@babel/helpers - typeof";
|
|
7
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Returns whether the value is an object.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
exports.
|
|
3
|
+
exports.string = exports.objectOf = exports.number = exports.mapOfValues = exports.literal = exports.enumOf = exports.callback = exports.boolean = exports.arrayOf = exports.anything = exports.anyOf = void 0;
|
|
4
4
|
|
|
5
5
|
var _chain = require("./chain");
|
|
6
6
|
|
|
@@ -24,6 +24,6 @@ export default ((container, html) => {
|
|
|
24
24
|
elements.forEach(element => {
|
|
25
25
|
appendNode(container, element);
|
|
26
26
|
});
|
|
27
|
-
executeInlineScripts(container, scripts
|
|
27
|
+
executeInlineScripts(container, scripts);
|
|
28
28
|
return executeRemoteScripts(scriptsUrls);
|
|
29
29
|
});
|
|
@@ -23,6 +23,6 @@ export default ((container, html) => {
|
|
|
23
23
|
elements.forEach(element => {
|
|
24
24
|
insertAfter(container, element);
|
|
25
25
|
});
|
|
26
|
-
executeInlineScripts(container, scripts
|
|
26
|
+
executeInlineScripts(container, scripts);
|
|
27
27
|
return executeRemoteScripts(scriptsUrls);
|
|
28
28
|
});
|
|
@@ -23,6 +23,6 @@ export default ((container, html) => {
|
|
|
23
23
|
elements.forEach(element => {
|
|
24
24
|
insertBefore(container, element);
|
|
25
25
|
});
|
|
26
|
-
executeInlineScripts(container, scripts
|
|
26
|
+
executeInlineScripts(container, scripts);
|
|
27
27
|
return executeRemoteScripts(scriptsUrls);
|
|
28
28
|
});
|
|
@@ -84,8 +84,11 @@ export const getRemoteScriptsUrls = fragment => {
|
|
|
84
84
|
|
|
85
85
|
return result;
|
|
86
86
|
};
|
|
87
|
-
export const executeInlineScripts = (
|
|
88
|
-
scripts.forEach(script =>
|
|
87
|
+
export const executeInlineScripts = (parent, scripts) => {
|
|
88
|
+
scripts.forEach(script => {
|
|
89
|
+
parent.appendChild(script);
|
|
90
|
+
parent.removeChild(script);
|
|
91
|
+
});
|
|
89
92
|
};
|
|
90
93
|
export const executeRemoteScripts = urls => {
|
|
91
94
|
return Promise.all(urls.map(loadScript));
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2022 Adobe. All rights reserved.
|
|
3
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
|
|
7
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
export default ":shadow";
|
|
@@ -13,5 +13,7 @@ export { default as awaitSelector } from "./awaitSelector";
|
|
|
13
13
|
export { default as appendNode } from "./appendNode";
|
|
14
14
|
export { default as createNode } from "./createNode";
|
|
15
15
|
export { default as matchesSelector } from "./matchesSelector";
|
|
16
|
+
export { default as querySelectorAll } from "./querySelectorAll";
|
|
16
17
|
export { default as removeNode } from "./removeNode";
|
|
17
|
-
export { default as selectNodes } from "./selectNodes";
|
|
18
|
+
export { default as selectNodes } from "./selectNodes";
|
|
19
|
+
export { default as selectNodesWithShadow } from "./selectNodesWithShadow";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2022 Adobe. All rights reserved.
|
|
3
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
|
|
7
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
import SHADOW_SEPARATOR from "../../constants/shadowSeparator";
|
|
13
|
+
export default (str => str.indexOf(SHADOW_SEPARATOR) !== -1);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2021 Adobe. All rights reserved.
|
|
3
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
|
|
7
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
import toArray from "../toArray";
|
|
13
|
+
export default ((context, selector) => toArray(context.querySelectorAll(selector)));
|
|
@@ -9,7 +9,9 @@ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTA
|
|
|
9
9
|
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
10
|
governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
|
-
import
|
|
12
|
+
import querySelectorAll from "./querySelectorAll";
|
|
13
|
+
import selectNodesWithShadow from "./selectNodesWithShadow";
|
|
14
|
+
import isShadowSelector from "./isShadowSelector";
|
|
13
15
|
/**
|
|
14
16
|
* Returns an array of matched DOM nodes.
|
|
15
17
|
* @param {String} selector
|
|
@@ -18,5 +20,9 @@ import toArray from "../toArray";
|
|
|
18
20
|
*/
|
|
19
21
|
|
|
20
22
|
export default ((selector, context = document) => {
|
|
21
|
-
|
|
23
|
+
if (!isShadowSelector(selector)) {
|
|
24
|
+
return querySelectorAll(context, selector);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return selectNodesWithShadow(context, selector);
|
|
22
28
|
});
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2021 Adobe. All rights reserved.
|
|
3
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
|
|
7
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
import querySelectorAll from "./querySelectorAll";
|
|
13
|
+
import startsWith from "../startsWith";
|
|
14
|
+
import SHADOW_SEPARATOR from "../../constants/shadowSeparator";
|
|
15
|
+
|
|
16
|
+
const splitWithShadow = selector => {
|
|
17
|
+
return selector.split(SHADOW_SEPARATOR);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const transformPrefix = (parent, selector) => {
|
|
21
|
+
const result = selector.trim();
|
|
22
|
+
const hasChildCombinatorPrefix = startsWith(result, ">");
|
|
23
|
+
|
|
24
|
+
if (!hasChildCombinatorPrefix) {
|
|
25
|
+
return result;
|
|
26
|
+
} // IE doesn't support :scope
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
if (window.document.documentMode) {
|
|
30
|
+
return result.substring(1).trim();
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const prefix = parent instanceof Element || parent instanceof HTMLDocument ? ":scope" : ":host"; // see https://bugs.webkit.org/show_bug.cgi?id=233380
|
|
34
|
+
|
|
35
|
+
return `${prefix} ${result}`;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export default ((context, selector) => {
|
|
39
|
+
// Shadow DOM should be supported
|
|
40
|
+
if (!window.document.documentElement.attachShadow) {
|
|
41
|
+
return querySelectorAll(context, selector.replace(SHADOW_SEPARATOR, ""));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const parts = splitWithShadow(selector);
|
|
45
|
+
|
|
46
|
+
if (parts.length < 2) {
|
|
47
|
+
return querySelectorAll(context, selector);
|
|
48
|
+
} // split the selector into parts separated by :shadow pseudo-selectors
|
|
49
|
+
// find each subselector element based on the previously selected node's shadowRoot
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
let parent = context;
|
|
53
|
+
|
|
54
|
+
for (let i = 0; i < parts.length; i += 1) {
|
|
55
|
+
const part = transformPrefix(parent, parts[i]);
|
|
56
|
+
const partNode = querySelectorAll(parent, part);
|
|
57
|
+
|
|
58
|
+
if (partNode.length === 0 || !partNode[0] || !partNode[0].shadowRoot) {
|
|
59
|
+
return partNode;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
parent = partNode[0].shadowRoot;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return undefined;
|
|
66
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/alloy",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.8.0",
|
|
4
4
|
"description": "Adobe Experience Platform Web SDK",
|
|
5
5
|
"main": "libEs5/index.js",
|
|
6
6
|
"module": "libEs6/index.js",
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"test:unit:coverage": "karma start --single-run --reporters spec,coverage",
|
|
20
20
|
"test:functional": "EDGE_BASE_PATH=\"ee-pre-prd\" ALLOY_ENV=\"int\" testcafe chrome",
|
|
21
21
|
"test:functional:watch": "EDGE_BASE_PATH=\"ee-pre-prd\" ALLOY_ENV=\"int\" ./scripts/watchFunctionalTests.js --browsers chrome",
|
|
22
|
+
"test:functional:debug": "EDGE_BASE_PATH=\"ee-pre-prd\" ALLOY_ENV=\"int\" testcafe --inspect-brk chrome",
|
|
22
23
|
"test:functional:build:int": "rollup -c --environment BASE_CODE_MIN,STANDALONE,NPM_PACKAGE_LOCAL",
|
|
23
24
|
"test:functional:build:prod": "rollup -c --environment BASE_CODE_MIN,NPM_PACKAGE_PROD",
|
|
24
25
|
"test:scripts": "jasmine --config=scripts/specs/jasmine.json",
|
|
@@ -63,20 +64,21 @@
|
|
|
63
64
|
"uuid": "^3.3.2"
|
|
64
65
|
},
|
|
65
66
|
"devDependencies": {
|
|
66
|
-
"@adobe/alloy": "^2.
|
|
67
|
+
"@adobe/alloy": "^2.8.0-beta.1",
|
|
67
68
|
"@babel/cli": "^7.12.8",
|
|
68
69
|
"@babel/core": "^7.2.2",
|
|
69
70
|
"@babel/plugin-proposal-object-rest-spread": "^7.3.2",
|
|
71
|
+
"@babel/plugin-transform-runtime": "^7.16.4",
|
|
70
72
|
"@babel/plugin-transform-template-literals": "^7.4.4",
|
|
71
73
|
"@babel/preset-env": "^7.4.5",
|
|
72
74
|
"@octokit/rest": "^18.3.5",
|
|
73
75
|
"babel-plugin-version": "^0.2.3",
|
|
74
76
|
"bundlesize": "^0.18.0",
|
|
75
77
|
"chalk": "^2.4.2",
|
|
76
|
-
"concurrently": "^5.
|
|
78
|
+
"concurrently": "^6.5.0",
|
|
77
79
|
"date-fns": "^2.23.0",
|
|
78
80
|
"dotenv": "^8.1.0",
|
|
79
|
-
"eslint": "^7.
|
|
81
|
+
"eslint": "^7.32.0",
|
|
80
82
|
"eslint-config-airbnb-base": "^14.0.0",
|
|
81
83
|
"eslint-config-prettier": "^6.4.0",
|
|
82
84
|
"eslint-plugin-ban": "^1.5.2",
|
|
@@ -86,7 +88,7 @@
|
|
|
86
88
|
"glob": "^7.1.3",
|
|
87
89
|
"husky": "^6.0.0",
|
|
88
90
|
"jasmine-core": "^3.4.0",
|
|
89
|
-
"karma": "^
|
|
91
|
+
"karma": "^6.3.9",
|
|
90
92
|
"karma-chrome-launcher": "^3.1.0",
|
|
91
93
|
"karma-coverage": "^2.0.1",
|
|
92
94
|
"karma-firefox-launcher": "^2.1.0",
|
|
@@ -95,7 +97,7 @@
|
|
|
95
97
|
"karma-jasmine-matchers": "^4.0.1",
|
|
96
98
|
"karma-rollup-preprocessor": "^7.0.5",
|
|
97
99
|
"karma-safari-launcher": "^1.0.0",
|
|
98
|
-
"karma-sauce-launcher": "^4.3.
|
|
100
|
+
"karma-sauce-launcher": "^4.3.6",
|
|
99
101
|
"karma-spec-reporter": "0.0.32",
|
|
100
102
|
"lint-staged": "^10.5.4",
|
|
101
103
|
"prettier": "^1.16.4",
|
|
@@ -113,10 +115,9 @@
|
|
|
113
115
|
"rollup-plugin-node-resolve": "^5.2.0",
|
|
114
116
|
"rollup-plugin-terser": "^7.0.2",
|
|
115
117
|
"start-server-and-test": "^1.10.6",
|
|
116
|
-
"testcafe": "^1.
|
|
117
|
-
"testcafe-browser-provider-saucelabs": "^1.8.
|
|
118
|
+
"testcafe": "^1.17.1",
|
|
119
|
+
"testcafe-browser-provider-saucelabs": "^1.8.3",
|
|
118
120
|
"testcafe-reporter-testrail": "^0.6.3",
|
|
119
|
-
"ua-parser": "^0.3.5",
|
|
120
121
|
"url-exists-nodejs": "^0.1.0",
|
|
121
122
|
"url-parse": "^1.4.7",
|
|
122
123
|
"yargs": "^16.2.0"
|