@olton/query
Advanced tools
Comparing version 0.4.0 to 0.4.1
{ | ||
"name": "@olton/query", | ||
"version": "0.4.0", | ||
"version": "0.4.1", | ||
"description": "Query is a minimalist JavaScript library for manipulating with HTML Elements", | ||
@@ -28,12 +28,6 @@ "main": "src/index.js", | ||
"browserslist": [ | ||
"last 2 versions", | ||
"not ie >= 0", | ||
"not ie_mob >= 0", | ||
"not op_mini all", | ||
"not op_mob >= 0", | ||
"not kaios >= 0", | ||
"not samsung >= 0", | ||
"not baidu >= 0", | ||
"not bb >= 0", | ||
"maintained node versions" | ||
"last 1 Chrome versions", | ||
"last 1 Firefox versions", | ||
"last 1 Opera versions", | ||
"last 1 Edge versions" | ||
], | ||
@@ -49,2 +43,3 @@ "devDependencies": { | ||
"jsdom-global": "3.0.2", | ||
"parcel": "^2.7.0", | ||
"rollup": "^2.75.5", | ||
@@ -51,0 +46,0 @@ "rollup-plugin-terser": "^7.0.2", |
@@ -65,40 +65,1 @@ export class DataSet { | ||
} | ||
export const QueryDataSet = { | ||
data(key, val){ | ||
let elem, data | ||
if (this.length === 0) { | ||
return | ||
} | ||
elem = this[0] | ||
if (!arguments.length) { | ||
data = $.dataset.get(elem) | ||
if (!data) { | ||
data = [] | ||
for(let attr of elem.attributes) { | ||
if (attr.startsWith('data-')) { | ||
data.push({attr: elem.getAttribute(attr)}) | ||
} | ||
} | ||
} | ||
return data | ||
} | ||
if (arguments.length === 1) { | ||
return $.dataset.get(elem, key) || $.dataset.attr(elem, key) | ||
} | ||
return this.each( function() { | ||
$.dataset.set( this, key, val ) | ||
}) | ||
}, | ||
removeData( key ) { | ||
return this.each( function() { | ||
$.dataset.remove( this, key ) | ||
}) | ||
} | ||
} |
@@ -135,2 +135,46 @@ import {each} from "../helpers/each.js" | ||
Query.use({ | ||
data(key, val){ | ||
let elem, data | ||
if (this.length === 0) { | ||
return | ||
} | ||
elem = this[0] | ||
if (!arguments.length) { | ||
data = $.dataset.get(elem) | ||
if (!data) { | ||
data = [] | ||
for(let attr of [...elem.attributes]) { | ||
const attrName = attr.name | ||
if (attrName.startsWith('data-')) { | ||
const obj = { | ||
[attrName]: elem.getAttribute(attrName) | ||
} | ||
// data.push([attrName, elem.getAttribute(attrName)]) | ||
data.push(obj) | ||
} | ||
} | ||
} | ||
return data | ||
} | ||
if (arguments.length === 1) { | ||
return $.dataset.get(elem, key) || $.dataset.attr(elem, key) | ||
} | ||
return this.each( function() { | ||
$.dataset.set( this, key, val ) | ||
}) | ||
}, | ||
removeData( key ) { | ||
return this.each( function() { | ||
$.dataset.remove( this, key ) | ||
}) | ||
} | ||
}) | ||
let _$ = globalThis.$ | ||
@@ -137,0 +181,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 4 instances in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 2 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10432828
135
8058
12
10