|
|
|
@ -1065,7 +1065,10 @@ function create_block(parent, name, nodes, context) {
|
|
|
|
|
after_update: [],
|
|
|
|
|
template: [],
|
|
|
|
|
metadata: {
|
|
|
|
|
template_needs_import_node: false,
|
|
|
|
|
context: {
|
|
|
|
|
template_needs_import_node: false,
|
|
|
|
|
template_contains_script_tag: false
|
|
|
|
|
},
|
|
|
|
|
namespace,
|
|
|
|
|
bound_contenteditable: context.state.metadata.bound_contenteditable
|
|
|
|
|
}
|
|
|
|
@ -1085,10 +1088,14 @@ function create_block(parent, name, nodes, context) {
|
|
|
|
|
node: id
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const callee = namespace === 'svg' ? '$.svg_template' : '$.template';
|
|
|
|
|
|
|
|
|
|
context.state.hoisted.push(
|
|
|
|
|
b.var(template_name, b.call(callee, b.template([b.quasi(state.template.join(''), true)], [])))
|
|
|
|
|
b.var(
|
|
|
|
|
template_name,
|
|
|
|
|
b.call(
|
|
|
|
|
get_template_function(namespace, state),
|
|
|
|
|
b.template([b.quasi(state.template.join(''), true)], [])
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
body.push(
|
|
|
|
@ -1097,7 +1104,7 @@ function create_block(parent, name, nodes, context) {
|
|
|
|
|
b.call(
|
|
|
|
|
'$.open',
|
|
|
|
|
b.id('$$anchor'),
|
|
|
|
|
b.literal(!state.metadata.template_needs_import_node),
|
|
|
|
|
b.literal(!state.metadata.context.template_needs_import_node),
|
|
|
|
|
template_name
|
|
|
|
|
)
|
|
|
|
|
),
|
|
|
|
@ -1138,12 +1145,14 @@ function create_block(parent, name, nodes, context) {
|
|
|
|
|
// special case — we can use `$.comment` instead of creating a unique template
|
|
|
|
|
body.push(b.var(id, b.call('$.comment', b.id('$$anchor'))));
|
|
|
|
|
} else {
|
|
|
|
|
const callee = namespace === 'svg' ? '$.svg_template' : '$.template';
|
|
|
|
|
|
|
|
|
|
state.hoisted.push(
|
|
|
|
|
b.var(
|
|
|
|
|
template_name,
|
|
|
|
|
b.call(callee, b.template([b.quasi(state.template.join(''), true)], []), b.true)
|
|
|
|
|
b.call(
|
|
|
|
|
get_template_function(namespace, state),
|
|
|
|
|
b.template([b.quasi(state.template.join(''), true)], []),
|
|
|
|
|
b.true
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
@ -1153,7 +1162,7 @@ function create_block(parent, name, nodes, context) {
|
|
|
|
|
b.call(
|
|
|
|
|
'$.open_frag',
|
|
|
|
|
b.id('$$anchor'),
|
|
|
|
|
b.literal(!state.metadata.template_needs_import_node),
|
|
|
|
|
b.literal(!state.metadata.context.template_needs_import_node),
|
|
|
|
|
template_name
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
@ -1217,6 +1226,23 @@ function create_block(parent, name, nodes, context) {
|
|
|
|
|
return body;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* @param {import('#compiler').Namespace} namespace
|
|
|
|
|
* @param {import('../types.js').ComponentClientTransformState} state
|
|
|
|
|
* @returns
|
|
|
|
|
*/
|
|
|
|
|
function get_template_function(namespace, state) {
|
|
|
|
|
const contains_script_tag = state.metadata.context.template_contains_script_tag;
|
|
|
|
|
return namespace === 'svg'
|
|
|
|
|
? contains_script_tag
|
|
|
|
|
? '$.svg_template_with_script'
|
|
|
|
|
: '$.svg_template'
|
|
|
|
|
: contains_script_tag
|
|
|
|
|
? '$.template_with_script'
|
|
|
|
|
: '$.template';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* @param {import('../types.js').ComponentClientTransformState} state
|
|
|
|
@ -1847,6 +1873,9 @@ export const template_visitors = {
|
|
|
|
|
context.state.template.push('<!>');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (node.name === 'script') {
|
|
|
|
|
context.state.metadata.context.template_contains_script_tag = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const metadata = context.state.metadata;
|
|
|
|
|
const child_metadata = {
|
|
|
|
@ -1885,7 +1914,7 @@ export const template_visitors = {
|
|
|
|
|
// custom element until the template is connected to the dom, which would
|
|
|
|
|
// cause problems when setting properties on the custom element.
|
|
|
|
|
// Therefore we need to use importNode instead, which doesn't have this caveat.
|
|
|
|
|
metadata.template_needs_import_node = true;
|
|
|
|
|
metadata.context.template_needs_import_node = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (const attribute of node.attributes) {
|
|
|
|
|