diff --git a/src/core/Parser.ts b/src/core/Parser.ts index 654edf2c..67971797 100644 --- a/src/core/Parser.ts +++ b/src/core/Parser.ts @@ -10,11 +10,6 @@ import { getTagName, } from "../internal"; -export interface ParseOptions { - state: "html" | "cdata" | "parsed-text" | "static-text"; - ignoreAttributes: boolean; -} - export interface Part { pos: number; endPos: number; @@ -54,7 +49,6 @@ export class Parser { public activePart!: Part; // The current part at the top of the part stack public forward!: boolean; public notifiers: ReturnType; - public userIsOpenTagOnly?: (tagName: string) => boolean; public currentOpenTag: STATE.OpenTagPart | undefined; // Used to reference the current open tag that is being parsed public currentAttribute: STATE.AttrPart | undefined; // Used to reference the current attribute that is being parsed public withinAttrGroup!: boolean; // Set to true if the parser is within a concise mode attribute group @@ -68,7 +62,7 @@ export class Parser { public endingMixedModeAtEOL?: boolean; // Used as a flag to record that the next EOL to exit HTML mode and go back to concise public textPos!: number; // Used to buffer text that is found within the body of a tag public text!: string; // Used to buffer text that is found within the body of a tag - public textParseMode!: ParseOptions["state"]; + public textParseMode!: "html" | "cdata" | "parsed-text" | "static-text"; public blockStack!: (( | STATE.OpenTagPart | { @@ -78,16 +72,9 @@ export class Parser { } ) & { body?: BODY_MODE; nestedIndent?: string })[]; // Used to keep track of HTML tags and HTML blocks - constructor( - listeners, - options?: { - concise?: boolean; - isOpenTagOnly?: (tagName: string) => boolean; - } - ) { + constructor(listeners) { this.reset(); this.notifiers = createNotifiers(this, listeners); - this.userIsOpenTagOnly = options?.isOpenTagOnly; } reset() { @@ -242,9 +229,7 @@ export class Parser { * are immediately closed. */ isOpenTagOnly(tagName: string) { - if (!tagName) return false; - tagName = tagName.toLowerCase(); - return this.userIsOpenTagOnly?.(tagName) ?? htmlTags.isOpenTagOnly(tagName); + return tagName ? htmlTags.isOpenTagOnly(tagName.toLowerCase()) : false; } addText(text: string) { diff --git a/src/states/OPEN_TAG.ts b/src/states/OPEN_TAG.ts index 380310bd..c61f68c9 100644 --- a/src/states/OPEN_TAG.ts +++ b/src/states/OPEN_TAG.ts @@ -1,4 +1,3 @@ -import type { ParseOptions } from "querystring"; import { CODE, STATE, @@ -30,7 +29,6 @@ export interface OpenTagPart extends Part { attributes: STATE.AttrPart[]; indent: string; nestedIndent?: string; - parseOptions?: Partial & Record; } export const OPEN_TAG: StateDefinition = { @@ -61,19 +59,8 @@ export const OPEN_TAG: StateDefinition = { exit(tag) { const tagName = tag.tagName; - const attributes = tag.attributes; - const parseOptions = tag.parseOptions; const selfClosed = tag.selfClosed; - - const ignoreAttributes = - parseOptions && parseOptions.ignoreAttributes === true; - - if (ignoreAttributes) { - attributes.length = 0; - } - const openTagOnly = (tag.openTagOnly = this.isOpenTagOnly(tagName.value)); - const origState = this.state; this.notifiers.notifyOpenTag(tag); diff --git a/src/util/notify-util.ts b/src/util/notify-util.ts index bf34f463..0dd26eda 100644 --- a/src/util/notify-util.ts +++ b/src/util/notify-util.ts @@ -90,11 +90,6 @@ export function createNotifiers(parser: Parser, listeners) { concise: tagInfo.concise, shorthandId: tagInfo.shorthandId, shorthandClassNames: tagInfo.shorthandClassNames, - setParseOptions(parseOptions) { - if (parseOptions) { - tagInfo.parseOptions = parseOptions; - } - }, }; eventFunc.call(parser, event, parser); @@ -136,22 +131,6 @@ export function createNotifiers(parser: Parser, listeners) { method: attr.method, bound: attr.bound, })), - setParseOptions(parseOptions) { - if (!parseOptions) { - return; - } - const newState = parseOptions.state; - - if (newState) { - if (newState === "parsed-text") { - parser.enterParsedTextContentState(); - } else if (newState === "static-text") { - parser.enterStaticTextContentState(); - } - } - - tagInfo.parseOptions = parseOptions; - }, }; eventFunc.call(parser, event, parser); diff --git a/test/autotest/commas-relax/test.js b/test/autotest/commas-relax/test.js deleted file mode 100644 index e3b2243e..00000000 --- a/test/autotest/commas-relax/test.js +++ /dev/null @@ -1,7 +0,0 @@ -exports.openTagNameHandlers = { - import: function(event) { - event.setParseOptions({ - relaxRequireCommas: true - }); - } -}; \ No newline at end of file diff --git a/test/autotest/ignoreAttributes/expected.html b/test/autotest/ignoreAttributes/expected.html deleted file mode 100644 index cbd94290..00000000 --- a/test/autotest/ignoreAttributes/expected.html +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/test/autotest/ignoreAttributes/input.htmljs b/test/autotest/ignoreAttributes/input.htmljs deleted file mode 100644 index 0b3a672c..00000000 --- a/test/autotest/ignoreAttributes/input.htmljs +++ /dev/null @@ -1 +0,0 @@ -static var startDate = new Date(); \ No newline at end of file diff --git a/test/autotest/ignoreAttributes/test.js b/test/autotest/ignoreAttributes/test.js deleted file mode 100644 index efe4881c..00000000 --- a/test/autotest/ignoreAttributes/test.js +++ /dev/null @@ -1,7 +0,0 @@ -exports.openTagNameHandlers = { - static: function(event) { - event.setParseOptions({ - ignoreAttributes: true - }); - } -}; \ No newline at end of file diff --git a/test/autotest/mixed-open-tag-only/expected.html b/test/autotest/mixed-open-tag-only/expected.html index ee8c1c0e..b4e429fd 100644 --- a/test/autotest/mixed-open-tag-only/expected.html +++ b/test/autotest/mixed-open-tag-only/expected.html @@ -5,10 +5,5 @@ text:"\n" - - - - -text:"\n"
diff --git a/test/autotest/mixed-open-tag-only/input.htmljs b/test/autotest/mixed-open-tag-only/input.htmljs index 81ec156f..a36a561a 100644 --- a/test/autotest/mixed-open-tag-only/input.htmljs +++ b/test/autotest/mixed-open-tag-only/input.htmljs @@ -1,6 +1,4 @@ var colors=['red', 'green', 'blue'] img src="marko2.png" -foo-img src="marko3.png" - div class="foo" \ No newline at end of file diff --git a/test/autotest/open-tag-only-custom/expected.html b/test/autotest/open-tag-only-custom/expected.html deleted file mode 100644 index de36e094..00000000 --- a/test/autotest/open-tag-only-custom/expected.html +++ /dev/null @@ -1,10 +0,0 @@ -
- text:"\n " - - - text:"\n " - - text:"Normally a link tag is open tag only" - - text:"\n" -
diff --git a/test/autotest/open-tag-only-custom/input.htmljs b/test/autotest/open-tag-only-custom/input.htmljs deleted file mode 100644 index 815ed3b5..00000000 --- a/test/autotest/open-tag-only-custom/input.htmljs +++ /dev/null @@ -1,4 +0,0 @@ -
- - Normally a link tag is open tag only -
\ No newline at end of file diff --git a/test/autotest/open-tag-only-custom/test.js b/test/autotest/open-tag-only-custom/test.js deleted file mode 100644 index 3f570fe8..00000000 --- a/test/autotest/open-tag-only-custom/test.js +++ /dev/null @@ -1,9 +0,0 @@ -exports.isOpenTagOnly = function(tagName) { - if (tagName === 'bar-img') { - return true; - } else if (tagName === 'link') { - return false; - } else { - return undefined; - } -}; \ No newline at end of file