Browse Source

Don't call successBeforeContentLoaded(head) redundantly

Jamie Birch 4 years ago
parent
commit
fb6d351352
1 changed files with 5 additions and 4 deletions
  1. 5
    4
      example/examples/Injection.tsx

+ 5
- 4
example/examples/Injection.tsx View File

@@ -65,12 +65,13 @@ export default class Injection extends Component<Props, State> {
65 65
 
66 66
               if(head){
67 67
                 declareSuccessBeforeContentLoaded(head);
68
+              } else {
69
+                window.self.document.addEventListener("DOMContentLoaded", function (event) {
70
+                  const head = (window.self.document.head || window.self.document.getElementsByTagName('head')[0]);
71
+                  declareSuccessBeforeContentLoaded(head);
72
+                });
68 73
               }
69 74
 
70
-              window.self.document.addEventListener("DOMContentLoaded", function (event) {
71
-                const head = (window.self.document.head || window.self.document.getElementsByTagName('head')[0]);
72
-                declareSuccessBeforeContentLoaded(head);
73
-              });
74 75
               `}
75 76
               
76 77
               injectedJavaScriptForMainFrameOnly={false}