@soda/get-current-script
Advanced tools
Comparing version
@@ -17,5 +17,12 @@ // addapted from the document.currentScript polyfill by Adam Miller | ||
function getCurrentScript () { | ||
if (document.currentScript) { | ||
const descriptor = Object.getOwnPropertyDescriptor(document, 'currentScript') | ||
// for chrome | ||
if (!descriptor && 'currentScript' in document && document.currentScript) { | ||
return document.currentScript | ||
} | ||
// for other browsers with native support for currentScript | ||
if (descriptor && descriptor.get !== getCurrentScript && document.currentScript) { | ||
return document.currentScript | ||
} | ||
@@ -22,0 +29,0 @@ // IE 8-10 support script readyState |
{ | ||
"name": "@soda/get-current-script", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "get the current executing script, with polyfills for IE9+ and Firefox", | ||
@@ -24,3 +24,3 @@ "main": "index.js", | ||
"devDependencies": { | ||
"chromedriver": "^80.0.1", | ||
"chromedriver": "^83.0.0", | ||
"geckodriver": "^1.19.1", | ||
@@ -30,3 +30,3 @@ "iedriver": "^3.14.1", | ||
"selenium-server": "^3.141.59", | ||
"serve": "^11.3.0", | ||
"serve": "^11.3.1", | ||
"start-server-and-test": "^1.10.8" | ||
@@ -33,0 +33,0 @@ }, |
@@ -19,3 +19,12 @@ module.exports = { | ||
.end() | ||
}, | ||
'use it as a polyfill': function (browser) { | ||
browser | ||
.url(`${browser.launch_url}/fixtures/test-polyfill.html`) | ||
.assert.containsText( | ||
'#app', | ||
'It works!' | ||
) | ||
.end() | ||
} | ||
} |
14530
7.96%14
16.67%270
8.43%