node-html-parser 2.2.0 → 2.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -477,7 +477,7 @@ export default class HTMLElement extends Node {
477
477
  }).join(' ');
478
478
  }
479
479
  hasAttribute(key) {
480
- return key in this.attrs;
480
+ return key.toLowerCase() in this.attrs;
481
481
  }
482
482
  /**
483
483
  * Get an attribute
@@ -495,10 +495,18 @@ export default class HTMLElement extends Node {
495
495
  if (arguments.length < 2) {
496
496
  throw new Error('Failed to execute \'setAttribute\' on \'Element\'');
497
497
  }
498
+ const k2 = key.toLowerCase();
498
499
  const attrs = this.rawAttributes;
500
+ for (const k in attrs) {
501
+ if (k.toLowerCase() === k2) {
502
+ key = k;
503
+ break;
504
+ }
505
+ }
499
506
  attrs[key] = String(value);
507
+ // update this.attrs
500
508
  if (this._attrs) {
501
- this._attrs[key] = decode(attrs[key]);
509
+ this._attrs[k2] = decode(attrs[key]);
502
510
  }
503
511
  // Update rawString
504
512
  this.rawAttrs = Object.keys(attrs).map((name) => {
package/dist/main.js CHANGED
@@ -1000,7 +1000,7 @@ define("nodes/html", ["require", "exports", "he", "nodes/node", "nodes/type", "n
1000
1000
  }).join(' ');
1001
1001
  };
1002
1002
  HTMLElement.prototype.hasAttribute = function (key) {
1003
- return key in this.attrs;
1003
+ return key.toLowerCase() in this.attrs;
1004
1004
  };
1005
1005
  /**
1006
1006
  * Get an attribute
@@ -1018,10 +1018,18 @@ define("nodes/html", ["require", "exports", "he", "nodes/node", "nodes/type", "n
1018
1018
  if (arguments.length < 2) {
1019
1019
  throw new Error('Failed to execute \'setAttribute\' on \'Element\'');
1020
1020
  }
1021
+ var k2 = key.toLowerCase();
1021
1022
  var attrs = this.rawAttributes;
1023
+ for (var k in attrs) {
1024
+ if (k.toLowerCase() === k2) {
1025
+ key = k;
1026
+ break;
1027
+ }
1028
+ }
1022
1029
  attrs[key] = String(value);
1030
+ // update this.attrs
1023
1031
  if (this._attrs) {
1024
- this._attrs[key] = decode(attrs[key]);
1032
+ this._attrs[k2] = decode(attrs[key]);
1025
1033
  }
1026
1034
  // Update rawString
1027
1035
  this.rawAttrs = Object.keys(attrs).map(function (name) {
@@ -564,7 +564,7 @@ var HTMLElement = /** @class */ (function (_super) {
564
564
  }).join(' ');
565
565
  };
566
566
  HTMLElement.prototype.hasAttribute = function (key) {
567
- return key in this.attrs;
567
+ return key.toLowerCase() in this.attrs;
568
568
  };
569
569
  /**
570
570
  * Get an attribute
@@ -582,10 +582,18 @@ var HTMLElement = /** @class */ (function (_super) {
582
582
  if (arguments.length < 2) {
583
583
  throw new Error('Failed to execute \'setAttribute\' on \'Element\'');
584
584
  }
585
+ var k2 = key.toLowerCase();
585
586
  var attrs = this.rawAttributes;
587
+ for (var k in attrs) {
588
+ if (k.toLowerCase() === k2) {
589
+ key = k;
590
+ break;
591
+ }
592
+ }
586
593
  attrs[key] = String(value);
594
+ // update this.attrs
587
595
  if (this._attrs) {
588
- this._attrs[key] = decode(attrs[key]);
596
+ this._attrs[k2] = decode(attrs[key]);
589
597
  }
590
598
  // Update rawString
591
599
  this.rawAttrs = Object.keys(attrs).map(function (name) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-html-parser",
3
- "version": "2.2.0",
3
+ "version": "2.2.1",
4
4
  "description": "A very fast HTML parser, generating a simplified DOM, with basic element query support.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/esm/index.js",