@percy/dom 1.31.8 → 1.31.9-beta.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.
Files changed (2) hide show
  1. package/dist/bundle.js +21 -1
  2. package/package.json +3 -3
package/dist/bundle.js CHANGED
@@ -131,6 +131,23 @@
131
131
  }
132
132
  }
133
133
 
134
+ let policy = null;
135
+ function getPolicy() {
136
+ if (typeof window !== 'undefined' && window.trustedTypes && window.trustedTypes.createPolicy) {
137
+ if (policy && policy.createHTML) return policy;
138
+ try {
139
+ policy = window.trustedTypes.createPolicy('percy-dom', {
140
+ // codeql[js/dom-text-reinterpreted-as-html]
141
+ createHTML: html => html
142
+ });
143
+ } catch (e) {
144
+ // ignore
145
+ }
146
+ /* istanbul ignore next */
147
+ return policy || {};
148
+ }
149
+ }
150
+
134
151
  // Adds a `<base>` element to the serialized iframe's `<head>`. This is necessary when
135
152
  // embedded documents are serialized and their contents become root-relative.
136
153
  function setBaseURI(dom) {
@@ -184,7 +201,10 @@
184
201
  for (let r of serialized.resources) resources.add(r);
185
202
 
186
203
  // assign serialized html to srcdoc and remove src
187
- cloneEl.setAttribute('srcdoc', serialized.html);
204
+ let p = getPolicy() || {};
205
+ try {
206
+ cloneEl.setAttribute('srcdoc', p.createHTML ? p.createHTML(serialized.html) : serialized.html);
207
+ } catch {}
188
208
  cloneEl.removeAttribute('src');
189
209
 
190
210
  // delete inaccessible frames built with js when js is disabled because they
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@percy/dom",
3
- "version": "1.31.8",
3
+ "version": "1.31.9-beta.0",
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": "latest"
12
+ "tag": "beta"
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": "f5c77f4e541aca84042d7249105428c55303e809"
38
+ "gitHead": "c16b5a6e67cb226d0ee258add9e10f055515ce65"
39
39
  }