@percy/dom 1.26.2-beta.0 → 1.26.3-alpha.4
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/bundle.js +60 -31
- package/package.json +3 -3
package/dist/bundle.js
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
(function() {
|
|
1
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
3
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
4
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
5
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
6
|
+
(function () {
|
|
2
7
|
(function (exports) {
|
|
3
8
|
'use strict';
|
|
4
9
|
|
|
5
|
-
const process =
|
|
10
|
+
const process = typeof globalThis !== "undefined" && globalThis.process || {};
|
|
6
11
|
process.env = process.env || {};
|
|
7
12
|
process.env.__PERCY_BROWSERIFIED__ = true;
|
|
8
13
|
|
|
@@ -195,15 +200,22 @@
|
|
|
195
200
|
}
|
|
196
201
|
return true;
|
|
197
202
|
}
|
|
203
|
+
function createStyleResource(styleSheet) {
|
|
204
|
+
const styles = Array.from(styleSheet.cssRules).map(cssRule => cssRule.cssText).join('\n');
|
|
205
|
+
let resource = resourceFromText(uid(), 'text/css', styles);
|
|
206
|
+
return resource;
|
|
207
|
+
}
|
|
198
208
|
function serializeCSSOM(_ref) {
|
|
199
209
|
let {
|
|
200
210
|
dom,
|
|
201
211
|
clone,
|
|
202
212
|
resources,
|
|
203
|
-
cache
|
|
213
|
+
cache,
|
|
214
|
+
warnings
|
|
204
215
|
} = _ref;
|
|
205
216
|
// in-memory CSSOM into their respective DOM nodes.
|
|
206
217
|
for (let styleSheet of dom.styleSheets) {
|
|
218
|
+
var _styleSheet$href;
|
|
207
219
|
if (isCSSOM(styleSheet)) {
|
|
208
220
|
let styleId = styleSheet.ownerNode.getAttribute('data-percy-element-id');
|
|
209
221
|
let cloneOwnerNode = clone.querySelector(`[data-percy-element-id="${styleId}"]`);
|
|
@@ -215,30 +227,49 @@
|
|
|
215
227
|
style.innerHTML = Array.from(styleSheet.cssRules).map(cssRule => cssRule.cssText).join('\n');
|
|
216
228
|
cloneOwnerNode.parentNode.insertBefore(style, cloneOwnerNode.nextSibling);
|
|
217
229
|
cloneOwnerNode.remove();
|
|
230
|
+
} else if ((_styleSheet$href = styleSheet.href) !== null && _styleSheet$href !== void 0 && _styleSheet$href.startsWith('blob:')) {
|
|
231
|
+
const styleLink = document.createElement('link');
|
|
232
|
+
styleLink.setAttribute('rel', 'stylesheet');
|
|
233
|
+
let resource = createStyleResource(styleSheet);
|
|
234
|
+
resources.add(resource);
|
|
235
|
+
styleLink.setAttribute('data-percy-blob-stylesheets-serialized', 'true');
|
|
236
|
+
styleLink.setAttribute('data-percy-serialized-attribute-href', resource.url);
|
|
237
|
+
|
|
238
|
+
/* istanbul ignore next: tested, but coverage is stripped */
|
|
239
|
+
if (clone.constructor.name === 'HTMLDocument' || clone.constructor.name === 'DocumentFragment') {
|
|
240
|
+
// handle document and iframe
|
|
241
|
+
clone.body.prepend(styleLink);
|
|
242
|
+
} else if (clone.constructor.name === 'ShadowRoot') {
|
|
243
|
+
clone.prepend(styleLink);
|
|
244
|
+
}
|
|
218
245
|
}
|
|
219
246
|
}
|
|
220
247
|
|
|
221
248
|
// clone Adopted Stylesheets
|
|
222
249
|
// Regarding ordering of the adopted stylesheets - https://github.com/WICG/construct-stylesheets/issues/93
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
clone.
|
|
250
|
+
/* istanbul ignore next: tested, but coverage is stripped */
|
|
251
|
+
if (dom.adoptedStyleSheets) {
|
|
252
|
+
for (let sheet of dom.adoptedStyleSheets) {
|
|
253
|
+
const styleLink = document.createElement('link');
|
|
254
|
+
styleLink.setAttribute('rel', 'stylesheet');
|
|
255
|
+
if (!cache.has(sheet)) {
|
|
256
|
+
let resource = createStyleResource(sheet);
|
|
257
|
+
resources.add(resource);
|
|
258
|
+
cache.set(sheet, resource.url);
|
|
259
|
+
}
|
|
260
|
+
styleLink.setAttribute('data-percy-adopted-stylesheets-serialized', 'true');
|
|
261
|
+
styleLink.setAttribute('data-percy-serialized-attribute-href', cache.get(sheet));
|
|
262
|
+
|
|
263
|
+
/* istanbul ignore next: tested, but coverage is stripped */
|
|
264
|
+
if (clone.constructor.name === 'HTMLDocument' || clone.constructor.name === 'DocumentFragment') {
|
|
265
|
+
// handle document and iframe
|
|
266
|
+
clone.body.prepend(styleLink);
|
|
267
|
+
} else if (clone.constructor.name === 'ShadowRoot') {
|
|
268
|
+
clone.prepend(styleLink);
|
|
269
|
+
}
|
|
241
270
|
}
|
|
271
|
+
} else {
|
|
272
|
+
warnings.add('Skipping `adoptedStyleSheets` as it is not supported.');
|
|
242
273
|
}
|
|
243
274
|
}
|
|
244
275
|
|
|
@@ -456,11 +487,12 @@
|
|
|
456
487
|
|
|
457
488
|
// Returns a copy or new doctype for a document.
|
|
458
489
|
function doctype(dom) {
|
|
490
|
+
var _ref2;
|
|
459
491
|
let {
|
|
460
492
|
name = 'html',
|
|
461
493
|
publicId = '',
|
|
462
494
|
systemId = ''
|
|
463
|
-
} = (dom === null || dom === void 0 ? void 0 : dom.doctype)
|
|
495
|
+
} = (_ref2 = dom === null || dom === void 0 ? void 0 : dom.doctype) !== null && _ref2 !== void 0 ? _ref2 : {};
|
|
464
496
|
let deprecated = '';
|
|
465
497
|
if (publicId && systemId) {
|
|
466
498
|
deprecated = ` PUBLIC "${publicId}" "${systemId}"`;
|
|
@@ -492,11 +524,10 @@
|
|
|
492
524
|
let percyElementId = shadowHost.getAttribute('data-percy-element-id');
|
|
493
525
|
let cloneShadowHost = ctx.clone.querySelector(`[data-percy-element-id="${percyElementId}"]`);
|
|
494
526
|
if (shadowHost.shadowRoot && cloneShadowHost.shadowRoot) {
|
|
495
|
-
serializeElements({
|
|
496
|
-
...ctx,
|
|
527
|
+
serializeElements(_objectSpread(_objectSpread({}, ctx), {}, {
|
|
497
528
|
dom: shadowHost.shadowRoot,
|
|
498
529
|
clone: cloneShadowHost.shadowRoot
|
|
499
|
-
});
|
|
530
|
+
}));
|
|
500
531
|
} else {
|
|
501
532
|
ctx.warnings.add('data-percy-shadow-host does not have shadowRoot');
|
|
502
533
|
}
|
|
@@ -546,18 +577,16 @@
|
|
|
546
577
|
};
|
|
547
578
|
return stringifyResponse ? JSON.stringify(result) : result;
|
|
548
579
|
}
|
|
549
|
-
|
|
550
580
|
exports["default"] = serializeDOM;
|
|
551
581
|
exports.serialize = serializeDOM;
|
|
552
582
|
exports.serializeDOM = serializeDOM;
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
583
|
+
Object.defineProperty(exports, '__esModule', {
|
|
584
|
+
value: true
|
|
585
|
+
});
|
|
556
586
|
})(this.PercyDOM = this.PercyDOM || {});
|
|
557
587
|
}).call(window);
|
|
558
|
-
|
|
559
588
|
if (typeof define === "function" && define.amd) {
|
|
560
589
|
define("@percy/dom", [], () => window.PercyDOM);
|
|
561
590
|
} else if (typeof module === "object" && module.exports) {
|
|
562
591
|
module.exports = window.PercyDOM;
|
|
563
|
-
}
|
|
592
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@percy/dom",
|
|
3
|
-
"version": "1.26.
|
|
3
|
+
"version": "1.26.3-alpha.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
},
|
|
10
10
|
"publishConfig": {
|
|
11
11
|
"access": "public",
|
|
12
|
-
"tag": "
|
|
12
|
+
"tag": "alpha"
|
|
13
13
|
},
|
|
14
14
|
"main": "dist/bundle.js",
|
|
15
15
|
"browser": "dist/bundle.js",
|
|
@@ -35,5 +35,5 @@
|
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"interactor.js": "^2.0.0-beta.10"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "d89ab97b8d5169eafd3eb42bdbbef41a2ac624ba"
|
|
39
39
|
}
|