-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
25 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,33 @@ | ||
export default { | ||
html: ` | ||
<div>foo</div> | ||
<div>foo<div>foo</div></div> | ||
`, | ||
ssrHtml: ` | ||
<noscript>foo</noscript> | ||
<div>foo<noscript>foo</noscript></div> | ||
<div>foo<div>foo<noscript>foo</noscript></div></div> | ||
`, | ||
test({ assert, target, compileOptions }) { | ||
// if created on client side, should not build noscript | ||
if (!compileOptions.hydratable) { | ||
assert.equal(target.querySelectorAll('noscript').length, 0); | ||
} | ||
|
||
// it's okay not to remove the node during hydration | ||
// will not be seen by user anyway | ||
removeNoScript(target); | ||
|
||
assert.htmlEqual( | ||
target.innerHTML, | ||
` | ||
<div>foo</div> | ||
<div>foo<div>foo</div></div> | ||
` | ||
); | ||
} | ||
}; | ||
|
||
function removeNoScript(target) { | ||
target.querySelectorAll("noscript").forEach(elem => { | ||
elem.parentNode.removeChild(elem); | ||
}); | ||
} |