1/** 2 * window.CustomEvent polyfill 3 */ 4;(function() { 5 'use strict'; 6 7 try 8 { 9 new window.CustomEvent('bx-test-custom-event', { 10 bubbles: true, 11 cancelable: true 12 }); 13 } 14 catch (exception) 15 { 16 var CustomEventPolyfill = function(event, params) 17 { 18 params = params || {}; 19 params.bubbles = !!params.bubbles; 20 params.cancelable = !!params.cancelable; 21 22 var customEvent = document.createEvent('CustomEvent'); 23 24 customEvent.initCustomEvent(event, params.bubbles, params.cancelable, params.detail); 25 26 var originalPreventFunction = customEvent.preventDefault; 27 28 customEvent.preventDefault = function() 29 { 30 Object.defineProperty(this, 'defaultPrevented', { 31 get: function() { return true; } 32 }); 33 34 originalPreventFunction.call(this); 35 }; 36 37 return customEvent; 38 }; 39 40 CustomEventPolyfill.prototype = window.Event.prototype; 41 42 window.CustomEvent = CustomEventPolyfill; 43 } 44 45})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.