Skip to content

Commit 075bf1e

Browse files
refactor(html): drop the foreign-tag branch a data: URL attribute cannot reach
Only HTML-namespace attributes are offered as data: URLs, and only a foreign element's /> reads back how a value ends.
1 parent ffc1272 commit 075bf1e

1 file changed

Lines changed: 12 additions & 19 deletions

File tree

‎lib/html/syntax-parser.js‎

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11159,14 +11159,12 @@ const _minifyOpenTag = (path, open) => {
1115911159
: null;
1116011160

1116111161
if (dataUrl !== null) {
11162-
const delimiter = sourceDelimiter;
11163-
const holdQuoted = tailIsRead && _S._deferEmbeddedSource !== undefined;
11162+
// HTML only, so no foreign `/>` reads back how this value ends.
1116411163
const asWritten =
11165-
written === null || holdQuoted
11166-
? ` ${attributeName}=${delimiter}${rawValue}${delimiter}`
11164+
written === null
11165+
? ` ${attributeName}=${sourceDelimiter}${rawValue}${sourceDelimiter}`
1116711166
: written.text;
11168-
const declinedTail =
11169-
!holdQuoted && written !== null && written.unquotedTail;
11167+
const declinedTail = written !== null && written.unquotedTail;
1117011168
/**
1117111169
* @param {string | null | undefined} rendered what the renderer answered
1117211170
* @returns {{ text: string, unquotedTail: boolean } | null} what to emit, or null where nothing it answered is written
@@ -11176,19 +11174,14 @@ const _minifyOpenTag = (path, open) => {
1117611174
return null;
1117711175
}
1117811176
const url = buildDataURI(dataUrl.parsed, rendered);
11179-
const answered = holdQuoted
11180-
? {
11181-
text: _writeQuotedAttribute(attributeName, url, delimiter),
11182-
unquotedTail: false
11183-
}
11184-
: _writeAttribute(
11185-
attributeName,
11186-
escapeAttribute(url, CC_QUOTATION_MARK, true),
11187-
rawValue,
11188-
url,
11189-
quoted,
11190-
sourceDelimiter
11191-
);
11177+
const answered = _writeAttribute(
11178+
attributeName,
11179+
escapeAttribute(url, CC_QUOTATION_MARK, true),
11180+
rawValue,
11181+
url,
11182+
quoted,
11183+
sourceDelimiter
11184+
);
1119211185

1119311186
return answered !== null && answered.text.length < asWritten.length
1119411187
? answered

0 commit comments

Comments
 (0)