|
|
@ -54,7 +54,12 @@ export default function(node: Element, renderer: Renderer, options: RenderOption
|
|
|
|
slot_scopes: Map<any, any>;
|
|
|
|
slot_scopes: Map<any, any>;
|
|
|
|
}) {
|
|
|
|
}) {
|
|
|
|
let opening_tag = `<${node.name}`;
|
|
|
|
let opening_tag = `<${node.name}`;
|
|
|
|
let textarea_contents; // awkward special case
|
|
|
|
let node_contents; // awkward special case
|
|
|
|
|
|
|
|
const contenteditable = (
|
|
|
|
|
|
|
|
node.name !== 'textarea' &&
|
|
|
|
|
|
|
|
node.name !== 'input' &&
|
|
|
|
|
|
|
|
node.attributes.some((attribute: Node) => attribute.name === 'contenteditable')
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
const slot = node.get_static_attribute_value('slot');
|
|
|
|
const slot = node.get_static_attribute_value('slot');
|
|
|
|
const component = node.find_nearest(/InlineComponent/);
|
|
|
|
const component = node.find_nearest(/InlineComponent/);
|
|
|
@ -91,7 +96,7 @@ export default function(node: Element, renderer: Renderer, options: RenderOption
|
|
|
|
args.push(snip(attribute.expression));
|
|
|
|
args.push(snip(attribute.expression));
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
if (attribute.name === 'value' && node.name === 'textarea') {
|
|
|
|
if (attribute.name === 'value' && node.name === 'textarea') {
|
|
|
|
textarea_contents = stringify_attribute(attribute, true);
|
|
|
|
node_contents = stringify_attribute(attribute, true);
|
|
|
|
} else if (attribute.is_true) {
|
|
|
|
} else if (attribute.is_true) {
|
|
|
|
args.push(`{ ${quote_name_if_necessary(attribute.name)}: true }`);
|
|
|
|
args.push(`{ ${quote_name_if_necessary(attribute.name)}: true }`);
|
|
|
|
} else if (
|
|
|
|
} else if (
|
|
|
@ -113,7 +118,7 @@ export default function(node: Element, renderer: Renderer, options: RenderOption
|
|
|
|
if (attribute.type !== 'Attribute') return;
|
|
|
|
if (attribute.type !== 'Attribute') return;
|
|
|
|
|
|
|
|
|
|
|
|
if (attribute.name === 'value' && node.name === 'textarea') {
|
|
|
|
if (attribute.name === 'value' && node.name === 'textarea') {
|
|
|
|
textarea_contents = stringify_attribute(attribute, true);
|
|
|
|
node_contents = stringify_attribute(attribute, true);
|
|
|
|
} else if (attribute.is_true) {
|
|
|
|
} else if (attribute.is_true) {
|
|
|
|
opening_tag += ` ${attribute.name}`;
|
|
|
|
opening_tag += ` ${attribute.name}`;
|
|
|
|
} else if (
|
|
|
|
} else if (
|
|
|
@ -146,6 +151,14 @@ export default function(node: Element, renderer: Renderer, options: RenderOption
|
|
|
|
|
|
|
|
|
|
|
|
if (name === 'group') {
|
|
|
|
if (name === 'group') {
|
|
|
|
// TODO server-render group bindings
|
|
|
|
// TODO server-render group bindings
|
|
|
|
|
|
|
|
} else if (contenteditable && (node === 'text' || node === 'html')) {
|
|
|
|
|
|
|
|
const snippet = snip(expression)
|
|
|
|
|
|
|
|
if (name == 'text') {
|
|
|
|
|
|
|
|
node_contents = '${@escape(' + snippet + ')}'
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// Do not escape HTML content
|
|
|
|
|
|
|
|
node_contents = '${' + snippet + '}'
|
|
|
|
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
const snippet = snip(expression);
|
|
|
|
const snippet = snip(expression);
|
|
|
|
opening_tag += ' ${(v => v ? ("' + name + '" + (v === true ? "" : "=" + JSON.stringify(v))) : "")(' + snippet + ')}';
|
|
|
|
opening_tag += ' ${(v => v ? ("' + name + '" + (v === true ? "" : "=" + JSON.stringify(v))) : "")(' + snippet + ')}';
|
|
|
@ -160,8 +173,8 @@ export default function(node: Element, renderer: Renderer, options: RenderOption
|
|
|
|
|
|
|
|
|
|
|
|
renderer.append(opening_tag);
|
|
|
|
renderer.append(opening_tag);
|
|
|
|
|
|
|
|
|
|
|
|
if (node.name === 'textarea' && textarea_contents !== undefined) {
|
|
|
|
if ((node.name === 'textarea' || contenteditable) && node_contents !== undefined) {
|
|
|
|
renderer.append(textarea_contents);
|
|
|
|
renderer.append(node_contents);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
renderer.render(node.children, options);
|
|
|
|
renderer.render(node.children, options);
|
|
|
|
}
|
|
|
|
}
|
|
|
|