Skip to content

Commit

Permalink
Revert "refactor(index): Collect attributes ourselves (#617)"
Browse files Browse the repository at this point in the history
This reverts commit 7869a0a.
  • Loading branch information
fb55 committed Aug 29, 2021
1 parent e9794d1 commit be1e9ba
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,23 +144,13 @@ export class DomHandler {
if (this.elementCB) this.elementCB(elem);
}

/** Attributes of the current element. */
private attribs: { [key: string]: string } = {};

public onopentagname(name: string): void {
this.attribs = {};
public onopentag(name: string, attribs: { [key: string]: string }): void {
const type = this.options.xmlMode ? ElementType.Tag : undefined;
const element = new Element(name, this.attribs, undefined, type);
const element = new Element(name, attribs, undefined, type);
this.addNode(element);
this.tagStack.push(element);
}

public onattribute(name: string, value: string): void {
if (!Object.prototype.hasOwnProperty.call(this.attribs, name)) {
this.attribs[name] = value;
}
}

public ontext(data: string): void {
const { lastNode } = this;

Expand Down

0 comments on commit be1e9ba

Please sign in to comment.