nativescript-angular icon indicating copy to clipboard operation
nativescript-angular copied to clipboard

[ANGULAR 9] - ERROR TypeError: null is not an object (evaluating 'view.root.sanitizer.sanitize'

Open mapo80 opened this issue 4 years ago • 1 comments

Environment Provide version numbers for the following components (information can be retrieved by running tns info in your project folder or by inspecting the package.json of the project):

  • CLI: 7.0.7
  • Cross-platform modules: 6.5.15
  • Android Runtime: 6.5.3
  • iOS Runtime: 6.5.2
  • NativeScript-Angular: 9.0.0
  • Angular: 9.1.0

Describe the bug

To Reproduce I've migrate my app from Ng 8 to Ng 9 and I have on console this error:

CONSOLE ERROR file: node_modules/@angular/core/fesm5/core.js:4127:0: ERROR TypeError: null is not an object (evaluating 'view.root.sanitizer.sanitize')

Error is here, view.root.sanitizer is null function setElementStyle(view, binding, renderNode, name, value) { var renderValue = view.root.sanitizer.sanitize(SecurityContext.STYLE, value);

To fix this I've added this on my webpack config:

    config.module.rules.unshift({
        test: /@angular\/core\/fesm5\/core\.js$/,
        use: [{
            loader: 'string-replace-loader',
            options: {
            search: 'var renderValue = view.root.sanitizer.sanitize(SecurityContext.STYLE, value);',
            replace: 'if (view.root.sanitizer == null) { return; }\n var renderValue = view.root.sanitizer.sanitize(SecurityContext.STYLE, value);',
            strict: true,
            },
        }],
    });   

This is a workaround, Is there a better way to solve this problem?

mapo80 avatar Sep 10 '20 09:09 mapo80

i've met the same question, do you find an answer to it ?

Weiee avatar Nov 28 '20 04:11 Weiee