Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: regression with nullish values in partial string attribute values (
- Loading branch information
1 parent
1fed43e
commit 144c352
Showing
12 changed files
with
63 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
"use strict"; | ||
|
||
exports.d = function(value) { | ||
return escapeDoubleQuotes(value + ""); | ||
}; | ||
|
||
exports.___escapeDoubleQuotes = escapeDoubleQuotes; | ||
|
||
exports.___escapeSingleQuotes = escapeSingleQuotes; | ||
|
||
function escapeSingleQuotes(value) { | ||
return escapeQuote(value, "'", "'"); | ||
} | ||
|
||
function escapeDoubleQuotes(value) { | ||
return escapeQuote(value, '"', """); | ||
} | ||
|
||
function escapeQuote(str, quote, escaped) { | ||
var result = ""; | ||
var lastPos = 0; | ||
|
||
for (var i = 0, len = str.length; i < len; i++) { | ||
if (str[i] === quote) { | ||
result += str.slice(lastPos, i) + escaped; | ||
lastPos = i + 1; | ||
} | ||
} | ||
|
||
if (lastPos) { | ||
return result + str.slice(lastPos); | ||
} | ||
|
||
return str; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
packages/marko/test/render/fixtures/attr-value-partial-string/expected.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<div data-foo="anull"></div><div data-foo="bnull"></div> |
2 changes: 2 additions & 0 deletions
2
packages/marko/test/render/fixtures/attr-value-partial-string/template.marko
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<div data-foo="a"+input.text/> | ||
<div data-foo=`b${input.text}`/> |
1 change: 1 addition & 0 deletions
1
packages/marko/test/render/fixtures/attr-value-partial-string/test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
exports.templateData = { text: null }; |
2 changes: 2 additions & 0 deletions
2
packages/marko/test/render/fixtures/attr-value-partial-string/vdom-expected.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<DIV data-foo="anull"> | ||
<DIV data-foo="bnull"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters