diff --git a/aio/content/errors/NG0910.md b/aio/content/errors/NG0910.md new file mode 100644 index 0000000000000..840bf4eba7511 --- /dev/null +++ b/aio/content/errors/NG0910.md @@ -0,0 +1,71 @@ +@name Unsafe bindings on an iframe element +@category runtime +@shortDescription Unsafe bindings on an iframe element + +@description +You see this error when Angular detects an attribute binding or a property binding on an ` +``` + +or when it's an attribute bindings: + +```html + +``` + +Also, the error is thrown when a similar pattern is used in Directive's host bindings: + +```typescript +@Directive({ + selector: 'iframe', + host: { + '[sandbox]': `'allow-scripts'`, + '[attr.sandbox]': `'allow-scripts'`, + } +}) +class IframeDirective {} +``` + +@debugging + +The error message includes the name of the component with the template where +an ` +``` + +If you need to have different values for these attributes (depending on various conditions), +you can use an `*ngIf` or an `*ngSwitch` on an ` + + +``` + + + + + + + +@reviewed 2022-05-27 diff --git a/goldens/public-api/core/errors.md b/goldens/public-api/core/errors.md index b0a0cc81bd624..abe94f54637ed 100644 --- a/goldens/public-api/core/errors.md +++ b/goldens/public-api/core/errors.md @@ -67,7 +67,7 @@ export const enum RuntimeErrorCode { // (undocumented) UNKNOWN_ELEMENT = 304, // (undocumented) - UNSAFE_IFRAME_ATTRS = 910, + UNSAFE_IFRAME_ATTRS = -910, // (undocumented) UNSAFE_VALUE_IN_RESOURCE_URL = 904, // (undocumented) diff --git a/packages/core/src/errors.ts b/packages/core/src/errors.ts index 6b2294603ac41..084c180e6cf65 100644 --- a/packages/core/src/errors.ts +++ b/packages/core/src/errors.ts @@ -63,7 +63,7 @@ export const enum RuntimeErrorCode { INVALID_INHERITANCE = 903, UNSAFE_VALUE_IN_RESOURCE_URL = 904, UNSAFE_VALUE_IN_SCRIPT = 905, - UNSAFE_IFRAME_ATTRS = 910, + UNSAFE_IFRAME_ATTRS = -910, } /** diff --git a/packages/core/test/acceptance/security_spec.ts b/packages/core/test/acceptance/security_spec.ts index fac9129a39f05..50d517ea0a887 100644 --- a/packages/core/test/acceptance/security_spec.ts +++ b/packages/core/test/acceptance/security_spec.ts @@ -47,7 +47,7 @@ describe('comment node text escaping', () => { describe('iframe processing', () => { function getErrorMessageRegexp() { - const errorMessagePart = 'NG0' + RuntimeErrorCode.UNSAFE_IFRAME_ATTRS.toString(); + const errorMessagePart = 'NG0' + Math.abs(RuntimeErrorCode.UNSAFE_IFRAME_ATTRS).toString(); return new RegExp(errorMessagePart); }