node-html-parser
Advanced tools
Comparing version 2.1.0 to 2.2.0
@@ -420,5 +420,6 @@ import he from 'he'; | ||
* Get attributes | ||
* @access private | ||
* @return {Object} parsed and unescaped attributes | ||
*/ | ||
get attributes() { | ||
get attrs() { | ||
if (this._attrs) { | ||
@@ -431,6 +432,15 @@ return this._attrs; | ||
const val = attrs[key] || ''; | ||
this._attrs[key] = decode(val); | ||
this._attrs[key.toLowerCase()] = decode(val); | ||
} | ||
return this._attrs; | ||
} | ||
get attributes() { | ||
const ret_attrs = {}; | ||
const attrs = this.rawAttributes; | ||
for (const key in attrs) { | ||
const val = attrs[key] || ''; | ||
ret_attrs[key] = decode(val); | ||
} | ||
return ret_attrs; | ||
} | ||
/** | ||
@@ -472,3 +482,3 @@ * Get escaped (as-it) attributes | ||
hasAttribute(key) { | ||
return key in this.attributes; | ||
return key in this.attrs; | ||
} | ||
@@ -480,3 +490,3 @@ /** | ||
getAttribute(key) { | ||
return this.attributes[key]; | ||
return this.attrs[key.toLowerCase()]; | ||
} | ||
@@ -483,0 +493,0 @@ /** |
@@ -929,5 +929,6 @@ var __extends = (this && this.__extends) || (function () { | ||
}); | ||
Object.defineProperty(HTMLElement.prototype, "attributes", { | ||
Object.defineProperty(HTMLElement.prototype, "attrs", { | ||
/** | ||
* Get attributes | ||
* @access private | ||
* @return {Object} parsed and unescaped attributes | ||
@@ -943,3 +944,3 @@ */ | ||
var val = attrs[key] || ''; | ||
this._attrs[key] = decode(val); | ||
this._attrs[key.toLowerCase()] = decode(val); | ||
} | ||
@@ -951,2 +952,15 @@ return this._attrs; | ||
}); | ||
Object.defineProperty(HTMLElement.prototype, "attributes", { | ||
get: function () { | ||
var ret_attrs = {}; | ||
var attrs = this.rawAttributes; | ||
for (var key in attrs) { | ||
var val = attrs[key] || ''; | ||
ret_attrs[key] = decode(val); | ||
} | ||
return ret_attrs; | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
Object.defineProperty(HTMLElement.prototype, "rawAttributes", { | ||
@@ -992,3 +1006,3 @@ /** | ||
HTMLElement.prototype.hasAttribute = function (key) { | ||
return key in this.attributes; | ||
return key in this.attrs; | ||
}; | ||
@@ -1000,3 +1014,3 @@ /** | ||
HTMLElement.prototype.getAttribute = function (key) { | ||
return this.attributes[key]; | ||
return this.attrs[key.toLowerCase()]; | ||
}; | ||
@@ -1003,0 +1017,0 @@ /** |
@@ -129,5 +129,7 @@ import Node from './node'; | ||
* Get attributes | ||
* @access private | ||
* @return {Object} parsed and unescaped attributes | ||
*/ | ||
get attributes(): Attributes; | ||
get attrs(): Attributes; | ||
get attributes(): Record<string, string>; | ||
/** | ||
@@ -134,0 +136,0 @@ * Get escaped (as-it) attributes |
@@ -493,5 +493,6 @@ "use strict"; | ||
}); | ||
Object.defineProperty(HTMLElement.prototype, "attributes", { | ||
Object.defineProperty(HTMLElement.prototype, "attrs", { | ||
/** | ||
* Get attributes | ||
* @access private | ||
* @return {Object} parsed and unescaped attributes | ||
@@ -507,3 +508,3 @@ */ | ||
var val = attrs[key] || ''; | ||
this._attrs[key] = decode(val); | ||
this._attrs[key.toLowerCase()] = decode(val); | ||
} | ||
@@ -515,2 +516,15 @@ return this._attrs; | ||
}); | ||
Object.defineProperty(HTMLElement.prototype, "attributes", { | ||
get: function () { | ||
var ret_attrs = {}; | ||
var attrs = this.rawAttributes; | ||
for (var key in attrs) { | ||
var val = attrs[key] || ''; | ||
ret_attrs[key] = decode(val); | ||
} | ||
return ret_attrs; | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
Object.defineProperty(HTMLElement.prototype, "rawAttributes", { | ||
@@ -556,3 +570,3 @@ /** | ||
HTMLElement.prototype.hasAttribute = function (key) { | ||
return key in this.attributes; | ||
return key in this.attrs; | ||
}; | ||
@@ -564,3 +578,3 @@ /** | ||
HTMLElement.prototype.getAttribute = function (key) { | ||
return this.attributes[key]; | ||
return this.attrs[key.toLowerCase()]; | ||
}; | ||
@@ -567,0 +581,0 @@ /** |
{ | ||
"name": "node-html-parser", | ||
"version": "2.1.0", | ||
"version": "2.2.0", | ||
"description": "A very fast HTML parser, generating a simplified DOM, with basic element query support.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -13,2 +13,3 @@ # Fast HTML Parser [![NPM version](https://badge.fury.io/js/node-html-parser.png)](http://badge.fury.io/js/node-html-parser) [![Build Status](https://travis-ci.org/taoqf/node-html-parser.svg?branch=master)](https://travis-ci.org/taoqf/node-html-parser) | ||
```shell | ||
@@ -18,2 +19,4 @@ npm install --save node-html-parser | ||
> Note: when using Fast HTML Parser in a Typescript project the minimum Typescript version supported is `^4.1.2`. | ||
## Performance | ||
@@ -20,0 +23,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
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
167455
4542
208