Socket
Socket
Sign inDemoInstall

custom-event-polyfill

Package Overview
Dependencies
0
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.2.2 to 0.3.0

.jshintrc

41

custom-event-polyfill.js

@@ -8,15 +8,34 @@ // Polyfill for creating CustomEvents on IE9/10/11

try {
new window.CustomEvent("test");
var ce = new window.CustomEvent('test');
ce.preventDefault();
if (ce.defaultPrevented !== true) {
// IE has problems with .preventDefault() on custom events
// http://stackoverflow.com/questions/23349191
throw new Error('Could not prevent default');
}
} catch(e) {
var CustomEvent = function(event, params) {
var evt;
params = params || {
bubbles: false,
cancelable: false,
detail: undefined
};
var CustomEvent = function(event, params) {
var evt, origPrevent;
params = params || {
bubbles: false,
cancelable: false,
detail: undefined
};
evt = document.createEvent("CustomEvent");
evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
return evt;
evt = document.createEvent("CustomEvent");
evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
origPrevent = evt.preventDefault;
evt.preventDefault = function () {
origPrevent.call(this);
try {
Object.defineProperty(this, 'defaultPrevented', {
get: function () {
return true;
}
});
} catch(e) {
this.defaultPrevented = true;
}
};
return evt;
};

@@ -23,0 +42,0 @@

module.exports = function(config) {
// Example set of browsers to run on Sauce Labs
// Check out https://saucelabs.com/platforms for all browser/platform combos
var customLaunchers = {
sl_ie_9: {
base: 'SauceLabs',
browserName: 'internet explorer',
platform: 'Windows 7',
version: '9'
},
sl_ie_10: {
base: 'SauceLabs',
browserName: 'internet explorer',
platform: 'Windows 7',
version: '10'
},
sl_ie_11: {
base: 'SauceLabs',
browserName: 'internet explorer',
platform: 'Windows 7',
version: '11'
},
sl_safari_8: {
base: 'SauceLabs',
browserName: 'safari',
platform: 'OS X 10.10',
version: '8.0'
},
sl_safari_7: {
base: 'SauceLabs',
browserName: 'safari',
platform: 'OS X 10.9',
version: '7.0'
},
sl_safari_ios: {
base: 'SauceLabs',
browserName: 'iphone',
platform: 'OS X 10.10',
version: '8.2',
deviceName: 'iPhone Simulator',
'device-orientation': 'portrait'
}
};
config.set({

@@ -51,16 +8,6 @@ basepath: '',

],
sauceLabs: {
testName: 'Custom Event Polyfill',
// username: '',
// accessKey: ''
},
frameworks: ['jasmine'],
customLaunchers: customLaunchers,
browsers: Object.keys(customLaunchers),
reporters: ['dots', 'saucelabs'],
reporters: ['dots'],
singleRun: true
});
};
{
"name": "custom-event-polyfill",
"version": "0.2.2",
"version": "0.3.0",
"author": [

@@ -8,2 +8,8 @@ "Mozilla Developer Network",

],
"contributors": [
"Frank Panetta (http://www.savvi.io)",
"Mikhail Reenko <reenko@yandex.ru>",
"Joscha Feth <joscha@feth.com> (http://www.feth.com)"
],
"license": "MIT",
"keywords": [

@@ -15,3 +21,3 @@ "polyfill",

],
"main": "./custom-event-polyfill.js",
"main": "custom-event-polyfill.js",
"repository": {

@@ -25,6 +31,6 @@ "type": "git",

"devDependencies": {
"jasmine-core": "^2.4.1",
"karma": "^0.12.31",
"karma-jasmine": "^0.3.5",
"karma-sauce-launcher": "^0.2.10"
"karma-jasmine": "^0.3.5"
}
}

@@ -0,1 +1,17 @@

# custom-event-polyfill
Polyfill for creating CustomEvents on IE9/10/11 if native implementation is missing.
## Install
```
$ npm install custom-event-polyfill
```
## Useage
https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent
## License
MIT

@@ -14,2 +14,8 @@ describe('custom-event-polyfill', function () {

});
});
it('should be possible to call .preventDefault', function() {
var ev = new CustomEvent('test', { cancelable: true });
ev.preventDefault();
expect(ev.defaultPrevented).toEqual(true);
});
});

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc