ignore noscript when claiming

pull/4297/head
Tan Li Hau 6 years ago
parent 98d58e06f6
commit 83fb842efa

@ -277,12 +277,7 @@ export default class ElementWrapper extends Wrapper {
render(block: Block, parent_node: Identifier, parent_nodes: Identifier) { render(block: Block, parent_node: Identifier, parent_nodes: Identifier) {
const { renderer } = this; const { renderer } = this;
if (this.node.name === 'noscript') { if (this.node.name === 'noscript') return;
if (renderer.options.hydratable) {
block.chunks.claim.push(b`@claim_noscript(${parent_nodes});`);
}
return;
}
if (this.slot_block) { if (this.slot_block) {
block = this.slot_block; block = this.slot_block;

@ -184,10 +184,6 @@ export function claim_space(nodes) {
return claim_text(nodes, ' '); return claim_text(nodes, ' ');
} }
export function claim_noscript(nodes) {
detach(claim_element(nodes, 'NOSCRIPT', {}, false));
}
function find_comment(nodes, text, start) { function find_comment(nodes, text, start) {
for (let i = start; i < nodes.length; i += 1) { for (let i = start; i < nodes.length; i += 1) {
const node = nodes[i]; const node = nodes[i];

@ -1,9 +1,4 @@
export default { export default {
html: `
<div>foo</div>
<div>foo<div>foo</div></div>
`,
ssrHtml: ` ssrHtml: `
<noscript>foo</noscript> <noscript>foo</noscript>
@ -11,4 +6,28 @@ export default {
<div>foo<div>foo<noscript>foo</noscript></div></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);
});
}

Loading…
Cancel
Save