Skip to content

Commit

Permalink
Add new stack top as an additional parameter for onItemPop
Browse files Browse the repository at this point in the history
  • Loading branch information
fb55 committed Feb 5, 2022
1 parent 8649dbe commit bc0a1f7
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/parse5/lib/parser/index.test.ts
Expand Up @@ -122,7 +122,7 @@ describe('parser', () => {
expect(onItemPush).toHaveBeenNthCalledWith(3, bodyElement);
expect(onItemPush).toHaveBeenLastCalledWith(bodyElement.childNodes[1]);
expect(onItemPop).toHaveBeenCalledTimes(2);
expect(onItemPop).toHaveBeenLastCalledWith(bodyElement.childNodes[0]);
expect(onItemPop).toHaveBeenLastCalledWith(bodyElement.childNodes[0], bodyElement);
});
});
});
2 changes: 1 addition & 1 deletion packages/parse5/lib/parser/index.ts
Expand Up @@ -326,7 +326,7 @@ export class Parser<T extends TreeAdapterTypeMap> {
this._setEndLocation(node, this.currentToken!);
}

this.treeAdapter.onItemPop?.(node);
this.treeAdapter.onItemPop?.(node, this.openElements.current);

if (isTop) {
let current;
Expand Down
2 changes: 1 addition & 1 deletion packages/parse5/lib/tree-adapters/interface.ts
Expand Up @@ -292,5 +292,5 @@ export interface TreeAdapter<T extends TreeAdapterTypeMap = TreeAdapterTypeMap>
*
* @param item The element being popped.
*/
onItemPop?: (item: T['element']) => void;
onItemPop?: (item: T['element'], newTop: T['parentNode']) => void;
}

0 comments on commit bc0a1f7

Please sign in to comment.