Skip to content

Commit

Permalink
_valueToNodeAttribute converts the empty string to `trustedTypes.em…
Browse files Browse the repository at this point in the history
…ptyScript` before setting, if available.
  • Loading branch information
bicknellr committed Jun 1, 2022
1 parent ce474db commit d69041c
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lib/mixins/properties-changed.js
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,13 @@ export const PropertiesChanged = dedupingMixin(
if (str === undefined) {
node.removeAttribute(attribute);
} else {
node.setAttribute(attribute, str);
node.setAttribute(
attribute,
// Closure's type for `setAttribute`'s second parameter incorrectly
// excludes `TrustedScript`.
(str === '' && window.trustedTypes) ?
/** @type {?} */ (window.trustedTypes.emptyScript) :
str);
}
}

Expand All @@ -550,9 +556,7 @@ export const PropertiesChanged = dedupingMixin(
_serializeValue(value) {
switch (typeof value) {
case 'boolean':
return value ?
(window.trustedTypes ? window.trustedTypes.emptyScript : '') :
undefined;
return value ? '' : undefined;
default:
return value != null ? value.toString() : undefined;
}
Expand Down

0 comments on commit d69041c

Please sign in to comment.