forked from ashi009/node-fast-html-parser
-
Notifications
You must be signed in to change notification settings - Fork 116
Closed
Description
Square brackets are not included in attribute key. When trying to access below
<input [(ngModel)]="foo">
Attribute key is parsed as (ngmodel) same goes for output from outerHTML
I'm trying to parse and refactor some angular templates. I'm unable to do that with parser working like that.
I think problem lies in below regular expression
/**
* Get escaped (as-is) attributes
* @return {Object} parsed attributes
*/
get: function () {
if (this._rawAttrs) {
return this._rawAttrs;
}
var attrs = {};
if (this.rawAttrs) {
var re = /([a-zA-Z()#][a-zA-Z0-9-_:()#]*)(?:\s*=\s*((?:'[^']*')|(?:"[^"]*")|\S+))?/g;
var match = void 0;
while (match = re.exec(this.rawAttrs)) {
var key = match[1];
var val = match[2] || null;
if (val && (val[0] === "'" || val[0] === "\"")) val = val.slice(1, val.length - 1);
attrs[key] = val;
}
}
this._rawAttrs = attrs;
return attrs;
}
Metadata
Metadata
Assignees
Labels
No labels