element-dataset
Advanced tools
Comparing version 1.2.0 to 1.3.0
// | ||
// element-dataset 1.0.0 | ||
// element-dataset 1.2.0 | ||
// | ||
@@ -41,4 +41,4 @@ // element-dataset is released under the terms of the BSD-3-Clause license. | ||
for (var index = 0; index < attributes.length; index++) { | ||
var attribute = attributes[index]; | ||
for (var i = 0; i < attributes.length; i++) { | ||
var attribute = attributes[i]; | ||
@@ -45,0 +45,0 @@ // This test really should allow any XML Name without |
// | ||
// element-dataset 1.0.0 | ||
// element-dataset 1.2.0 | ||
// | ||
@@ -5,0 +5,0 @@ // element-dataset is released under the terms of the BSD-3-Clause license. |
'use strict'; | ||
function elementDatasetPolyfill () { | ||
if (!document.documentElement.dataset && | ||
( | ||
!Object.getOwnPropertyDescriptor(Element.prototype, 'dataset') || | ||
!Object.getOwnPropertyDescriptor(Element.prototype, 'dataset').get | ||
) | ||
) { | ||
const descriptor = {} | ||
function elementDatasetPolyfill() { | ||
if (!document.documentElement.dataset && (!Object.getOwnPropertyDescriptor(Element.prototype, 'dataset') || !Object.getOwnPropertyDescriptor(Element.prototype, 'dataset').get)) { | ||
var descriptor = {}; | ||
descriptor.enumerable = true | ||
descriptor.enumerable = true; | ||
descriptor.get = function () { | ||
const element = this | ||
const map = {} | ||
const attributes = this.attributes | ||
var element = this; | ||
var map = {}; | ||
var attributes = this.attributes; | ||
function toUpperCase (n0) { | ||
return n0.charAt(1).toUpperCase() | ||
function toUpperCase(n0) { | ||
return n0.charAt(1).toUpperCase(); | ||
} | ||
function getter () { | ||
return this.value | ||
function getter() { | ||
return this.value; | ||
} | ||
function setter (name, value) { | ||
function setter(name, value) { | ||
if (typeof value !== 'undefined') { | ||
this.setAttribute(name, value) | ||
this.setAttribute(name, value); | ||
} else { | ||
this.removeAttribute(name); | ||
} | ||
else { | ||
this.removeAttribute(name) | ||
} | ||
} | ||
for (let index = 0; index < attributes.length; index++) { | ||
const attribute = attributes[index] | ||
for (var i = 0; i < attributes.length; i++) { | ||
var attribute = attributes[i]; | ||
@@ -42,21 +36,21 @@ // This test really should allow any XML Name without | ||
if (attribute && attribute.name && (/^data-\w[\w\-]*$/).test(attribute.name)) { | ||
const name = attribute.name | ||
const value = attribute.value | ||
if (attribute && attribute.name && /^data-\w[\w\-]*$/.test(attribute.name)) { | ||
var name = attribute.name; | ||
var value = attribute.value; | ||
// Change to CamelCase | ||
const propName = name.substr(5).replace(/-./g, toUpperCase) | ||
var propName = name.substr(5).replace(/-./g, toUpperCase); | ||
Object.defineProperty(map, propName, { | ||
enumerable: this.enumerable, | ||
get: getter.bind({value: value || ''}), | ||
get: getter.bind({ value: value || '' }), | ||
set: setter.bind(element, name) | ||
}) | ||
}); | ||
} | ||
} | ||
return map | ||
} | ||
return map; | ||
}; | ||
Object.defineProperty(Element.prototype, 'dataset', descriptor) | ||
Object.defineProperty(Element.prototype, 'dataset', descriptor); | ||
} | ||
@@ -63,0 +57,0 @@ } |
'use strict'; | ||
function elementDatasetPolyfill () { | ||
if (!document.documentElement.dataset && | ||
( | ||
!Object.getOwnPropertyDescriptor(Element.prototype, 'dataset') || | ||
!Object.getOwnPropertyDescriptor(Element.prototype, 'dataset').get | ||
) | ||
) { | ||
const descriptor = {} | ||
function elementDatasetPolyfill() { | ||
if (!document.documentElement.dataset && (!Object.getOwnPropertyDescriptor(Element.prototype, 'dataset') || !Object.getOwnPropertyDescriptor(Element.prototype, 'dataset').get)) { | ||
var descriptor = {}; | ||
descriptor.enumerable = true | ||
descriptor.enumerable = true; | ||
descriptor.get = function () { | ||
const element = this | ||
const map = {} | ||
const attributes = this.attributes | ||
var element = this; | ||
var map = {}; | ||
var attributes = this.attributes; | ||
function toUpperCase (n0) { | ||
return n0.charAt(1).toUpperCase() | ||
function toUpperCase(n0) { | ||
return n0.charAt(1).toUpperCase(); | ||
} | ||
function getter () { | ||
return this.value | ||
function getter() { | ||
return this.value; | ||
} | ||
function setter (name, value) { | ||
function setter(name, value) { | ||
if (typeof value !== 'undefined') { | ||
this.setAttribute(name, value) | ||
this.setAttribute(name, value); | ||
} else { | ||
this.removeAttribute(name); | ||
} | ||
else { | ||
this.removeAttribute(name) | ||
} | ||
} | ||
for (let index = 0; index < attributes.length; index++) { | ||
const attribute = attributes[index] | ||
for (var i = 0; i < attributes.length; i++) { | ||
var attribute = attributes[i]; | ||
@@ -42,21 +36,21 @@ // This test really should allow any XML Name without | ||
if (attribute && attribute.name && (/^data-\w[\w\-]*$/).test(attribute.name)) { | ||
const name = attribute.name | ||
const value = attribute.value | ||
if (attribute && attribute.name && /^data-\w[\w\-]*$/.test(attribute.name)) { | ||
var name = attribute.name; | ||
var value = attribute.value; | ||
// Change to CamelCase | ||
const propName = name.substr(5).replace(/-./g, toUpperCase) | ||
var propName = name.substr(5).replace(/-./g, toUpperCase); | ||
Object.defineProperty(map, propName, { | ||
enumerable: this.enumerable, | ||
get: getter.bind({value: value || ''}), | ||
get: getter.bind({ value: value || '' }), | ||
set: setter.bind(element, name) | ||
}) | ||
}); | ||
} | ||
} | ||
return map | ||
} | ||
return map; | ||
}; | ||
Object.defineProperty(Element.prototype, 'dataset', descriptor) | ||
Object.defineProperty(Element.prototype, 'dataset', descriptor); | ||
} | ||
@@ -63,0 +57,0 @@ } |
{ | ||
"name": "element-dataset", | ||
"description": "HTMLElement.dataset polyfill", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"homepage": "https://github.com/epiloque/element-dataset", | ||
@@ -60,3 +60,3 @@ "author": { | ||
"karma-mocha": "^0.2.2", | ||
"karma-mocha-reporter": "^1.2.2", | ||
"karma-mocha-reporter": "^2.0.0", | ||
"karma-phantomjs-launcher": "^1.0.0", | ||
@@ -69,2 +69,3 @@ "mkdirp": "^0.5.1", | ||
"rollup": "^0.25.4", | ||
"rollup-plugin-babel": "^2.4.0", | ||
"stream-to-promise": "^1.1.0", | ||
@@ -75,2 +76,3 @@ "uglify-js": "^2.6.2", | ||
"babel": { | ||
"babelrc": "false", | ||
"presets": [ | ||
@@ -77,0 +79,0 @@ "es2015" |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
0
12485
27
157