Skip to content

Commit ef19bf4

Browse files
committed
fix issue #200
1 parent ebaa80d commit ef19bf4

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

src/nodes/html.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@ export default class HTMLElement extends Node {
687687
}
688688
const attrs = {} as RawAttributes;
689689
if (this.rawAttrs) {
690-
const re = /([a-zA-Z()#][a-zA-Z0-9-_:()#]*)(?:\s*=\s*((?:'[^']*')|(?:"[^"]*")|\S+))?/g;
690+
const re = /([a-zA-Z()[\]#][a-zA-Z0-9-_:()[\]#]*)(?:\s*=\s*((?:'[^']*')|(?:"[^"]*")|\S+))?/g;
691691
let match: RegExpExecArray;
692692
while ((match = re.exec(this.rawAttrs))) {
693693
const key = match[1];

test/tests/issues/200.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const { parse } = require('@test/test-target');
2+
3+
// https://github.com/taoqf/node-html-parser/issues/186
4+
describe('angular template', function () {
5+
it('attribute name contains []', function () {
6+
const root = parse('<input [(ngModel)]="foo">');
7+
const input = root.firstChild;
8+
'foo'.should.eql(input.getAttribute('[(ngModel)]'));
9+
root.toString().should.eql('<input [(ngModel)]="foo">');
10+
});
11+
});

test/tests/issues/207.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const { parse } = require('@test/test-target');
22

3-
// https://github.com/taoqf/node-html-parser/issues/206
3+
// https://github.com/taoqf/node-html-parser/pull/207
44
describe('void tags', function () {
55
it('default', function () {
66
const root = parse('<div><br></div>');

0 commit comments

Comments
 (0)