Skip to content

Commit 38fb44d

Browse files
committed
Add trustedTypes.defaultPolicy getter. Fixes #185. (#206)
1 parent 77667b8 commit 38fb44d

16 files changed

+189
-110
lines changed

dist/cjs/trustedtypes.api_only.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,13 +629,19 @@ const trustedTypesBuilderTestOnly = function() {
629629
getPropertyType,
630630
getTypeMapping,
631631
emptyHTML,
632+
defaultPolicy, // Just to make the compiler happy, this is overridden below.
632633

633634
TrustedHTML: TrustedHTML,
634635
TrustedURL: TrustedURL,
635636
TrustedScriptURL: TrustedScriptURL,
636637
TrustedScript: TrustedScript,
637638
});
638639

640+
defineProperty(api, 'defaultPolicy', {
641+
get: getDefaultPolicy,
642+
set: () => {},
643+
});
644+
639645
return {
640646
trustedTypes: freeze(api),
641647
setAllowedPolicyNames,
@@ -697,6 +703,11 @@ function setupPolyfill() {
697703
'emptyHTML': tt.emptyHTML,
698704
'_isPolyfill_': true,
699705
});
706+
Object.defineProperty(
707+
publicApi,
708+
'defaultPolicy',
709+
Object.getOwnPropertyDescriptor(tt, 'defaultPolicy') || {});
710+
700711
window[rootProperty] = Object.freeze(publicApi);
701712

702713
window['TrustedHTML'] = tt.TrustedHTML;

dist/es5/trustedtypes.api_only.build.js

Lines changed: 16 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/es5/trustedtypes.api_only.build.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/es5/trustedtypes.build.js

Lines changed: 40 additions & 40 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/es5/trustedtypes.build.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/es6/trustedtypes.api_only.build.js

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/es6/trustedtypes.api_only.build.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)