react-virtualized icon indicating copy to clipboard operation
react-virtualized copied to clipboard

Failed to execute 'createPolicy' on 'TrustedTypePolicyFactory'

Open codejunkienick opened this issue 4 years ago • 8 comments

Bug Report

What is the current behavior?

React-virtualized triggers this error Failed to execute 'createPolicy' on 'TrustedTypePolicyFactory': Policy with name react-virtualized-auto-sizer already exists.

What is the expected behavior?

react-virtualized checks for existing policy

Which versions of React and react-virtualized, and which browser / OS are affected by this issue? Did this work in previous versions of react-virtualized?

Worked on previous versions. Most likely latest release with trusted types triggered this.

Browser any
OS any
React 16.4.0
React DOM 16.4.0
react-virtualized 9.22.3

Code that triggers error is in react-virtualized/dist/es/vendor/detectElementResize.js

        element.__resizeListeners__ = [];
        (element.__resizeTriggers__ = doc.createElement('div')).className = 'resize-triggers';
        var resizeTriggersHtml = '<div class="expand-trigger"><div></div></div>' + '<div class="contract-trigger"></div>';
        if (window.trustedTypes) {
          var staticPolicy = trustedTypes.createPolicy('react-virtualized-auto-sizer', {
            createHTML: function createHTML() {
              return resizeTriggersHtml;
            }
          });
          element.__resizeTriggers__.innerHTML = staticPolicy.createHTML('');

codejunkienick avatar Feb 05 '21 05:02 codejunkienick

MiuiBrowser 12.9.3
XiaoMi Mi 10T
Android 10

HZ-labs avatar Mar 26 '21 15:03 HZ-labs

Reproducible by:

  1. Enable the #enable-experimental-web-platform-features Chrome flag on chrome://flags. (This is what causes window.trustedTypes to exist)
  2. Mount two <AutoSizer/> components on the same page.

KurtPreston avatar Jun 30 '21 21:06 KurtPreston

Noticed this was fixed by #1627, though code has not yet been published to a new version.

KurtPreston avatar Jun 30 '21 21:06 KurtPreston

We're also impacted by this issue. @bvaughn it seems that the bug has already been fixed but not published. Is there something we could do to help?

MaximeCheramy avatar Jan 11 '22 10:01 MaximeCheramy

any update on this? We're also impacted by this and it seems as simple as publishing a new release @bvaughn

rahul-sharma-uipath avatar Feb 08 '22 21:02 rahul-sharma-uipath

Same here

rxflamel avatar Apr 25 '22 18:04 rxflamel

Same here+1

zhoushan1 avatar Jul 20 '22 02:07 zhoushan1

Same here+1

Leonardo-zyh avatar Jul 14 '23 10:07 Leonardo-zyh