-
-
Notifications
You must be signed in to change notification settings - Fork 213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Angular-innerHTML is not rendered #1638
Comments
What version are you using? This issue has been fixed in the latest release. |
Should be the latest Version (15.11.7): package.json // jest.config.ts
import type { Config } from 'jest';
export default <Config>{
preset: 'jest-preset-angular',
setupFilesAfterEnv: [`${__dirname}/tests/setup.ts`],
testEnvironment: '@happy-dom/jest-environment',
testEnvironmentOptions: {
width: 1920,
height: 1080,
},
};
I also found Tickets, that i thought were similar, but not related: I would try to figure it out myself, but it may take a while. |
I think I was mixing up the sanitizer with another issue as I have fixed it using patch-package on our project.
|
That did the trick! I had to make the changes in the cjs-folder, but now everything renders correctly. |
Thank you for reporting @SpaxR! 🙂 This should now be fixed in v16.0.0, so the patch should not be necessary anymore. |
Describe the bug
When using [innerHTML]-Directive in Angular, nothing is put into the DOM.
With JSDom or Karma the content exists in the Document.
To Reproduce
CodeSandbox
happy-dom
/@happy-dom/jest-environment
<div [innerHTML]="'TEST'"></div>
expect(fixture.nativeElement.innerHTML).toContain('TEST')
<div></div>
Expected behavior
Angular should be able to render innerHTML into the DOM
Additional context
With a real browser, karma, or jest/jsdom the innerHTML is displayed,
so i guess the Problem is somewhere between happydom and Angular.
Angular doesn't trust the Content that gets provided via innerHTML, unless it can determine that it is "safe".
It is possible to bypass the security with Angular's DomSanitizer, but that gets hard to apply to third-party libraries.
My guess is that happy-dom does something that Angular doesn't deem safe,
and that's the point where my knowledge ends and help would be much appreciated.
The text was updated successfully, but these errors were encountered: