This repository was archived by the owner on Feb 26, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +13
-2
lines changed Expand file tree Collapse file tree 3 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,11 @@ var utils = require('../utils');
66var eventNames = 'copy cut paste abort blur focus canplay canplaythrough change click contextmenu dblclick drag dragend dragenter dragleave dragover dragstart drop durationchange emptied ended input invalid keydown keypress keyup load loadeddata loadedmetadata loadstart message mousedown mouseenter mouseleave mousemove mouseout mouseover mouseup pause play playing progress ratechange reset scroll seeked seeking select show stalled submit suspend timeupdate volumechange waiting mozfullscreenchange mozfullscreenerror mozpointerlockchange mozpointerlockerror error webglcontextrestored webglcontextlost webglcontextcreationerror' . split ( ' ' ) ;
77
88function apply ( ) {
9+ if ( utils . isWebWorker ( ) ) {
10+ // on WebWorker so don't apply patch
11+ return ;
12+ }
13+
914 if ( canPatchViaPropertyDescriptor ( ) ) {
1015 // for browsers that we can patch the descriptor: Chrome & Firefox
1116 var onEventNames = eventNames . map ( function ( property ) {
Original file line number Diff line number Diff line change 11'use strict' ;
22
33var _redefineProperty = require ( './define-property' ) . _redefineProperty ;
4+ var utils = require ( "../utils" ) ;
45
56function apply ( ) {
6- if ( ! ( 'registerElement' in global . document ) ) {
7+ if ( utils . isWebWorker ( ) || ! ( 'registerElement' in global . document ) ) {
78 return ;
89 }
910
Original file line number Diff line number Diff line change @@ -29,6 +29,10 @@ function patchPrototype(obj, fnNames) {
2929 } ) ;
3030} ;
3131
32+ function isWebWorker ( ) {
33+ return ( typeof document === "undefined" ) ;
34+ }
35+
3236function patchProperty ( obj , prop ) {
3337 var desc = Object . getOwnPropertyDescriptor ( obj , prop ) || {
3438 enumerable : true ,
@@ -178,5 +182,6 @@ module.exports = {
178182 patchProperty : patchProperty ,
179183 patchProperties : patchProperties ,
180184 patchEventTargetMethods : patchEventTargetMethods ,
181- patchClass : patchClass
185+ patchClass : patchClass ,
186+ isWebWorker : isWebWorker
182187} ;
You can’t perform that action at this time.
0 commit comments