| Current Path : /var/www/homesaver/www/bitrix/js/main/polyfill/customevent/ |
| Current File : /var/www/homesaver/www/bitrix/js/main/polyfill/customevent/main.polyfill.customevent.js |
/**
* window.CustomEvent polyfill
*/
;(function() {
'use strict';
try
{
new window.CustomEvent('bx-test-custom-event', {
bubbles: true,
cancelable: true
});
}
catch (exception)
{
var CustomEventPolyfill = function(event, params)
{
params = params || {};
params.bubbles = !!params.bubbles;
params.cancelable = !!params.cancelable;
var customEvent = document.createEvent('CustomEvent');
customEvent.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
var originalPreventFunction = customEvent.preventDefault;
customEvent.preventDefault = function()
{
Object.defineProperty(this, 'defaultPrevented', {
get: function() { return true; }
});
originalPreventFunction.call(this);
};
return customEvent;
};
CustomEventPolyfill.prototype = window.Event.prototype;
window.CustomEvent = CustomEventPolyfill;
}
})();