Commit 8c53d40b authored by David Sveningsson's avatar David Sveningsson
Browse files

feat(parser): add DOCTYPE tag to `DoctypeEvent`

parent a40e28e2
......@@ -55,18 +55,18 @@ Emitted after the parsing has finished loading the DOM tree.
### `doctype`
```typescript
{
location: Location,
value: string,
valueLocation: Location,
interface DoctypeEvent {
location: Location;
tag: string;
value: string;
valueLocation: Location;
}
```
Emitted when a doctype is encountered. `value` is the doctype (without
`<doctype` and `>`).
Emitted when a DOCTYPE is encountered.
`tag` is the tag used to open and `value` is the doctype value (without `<!doctype` and `>`).
`location` refers to the doctype opening tag and `valueLocation` to the value
(as described above)
`location` refers to the doctype opening tag and `valueLocation` to the value (as described above)
## DOM Nodes
......
......@@ -158,6 +158,9 @@ export interface DoctypeEvent extends Event {
/** Event location. */
location: Location;
/** Tag */
tag: string;
/** Selected doctype */
value: string;
......
......@@ -892,6 +892,7 @@ describe("parser", () => {
const dom = parser.parseHtml("<!doctype foobar>");
expect(events.shift()).toEqual({
event: "doctype",
tag: "doctype",
value: "foobar",
valueLocation: expect.objectContaining({
line: 1,
......
......@@ -454,6 +454,7 @@ export class Parser {
const value = doctype.data[0];
this.dom.doctype = value;
this.trigger("doctype", {
tag: startToken.data[1],
value,
valueLocation: tokens[0].location,
location: startToken.location,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment