pull/8434/head
baseballyama 3 years ago
parent aadda27bea
commit 1ed69fa0f2

@ -63,7 +63,7 @@ export default function (node: Element, renderer: Renderer, options: RenderOptio
const attr_name = node.namespace === namespaces.foreign ? attribute.name : fix_attribute_casing(attribute.name);
const name = attribute.name.toLowerCase();
if (name === 'value' && node.name.toLowerCase() === 'textarea') {
node_contents = get_attribute_value(attribute, true);
node_contents = get_attribute_value(attribute);
} else if (attribute.is_true) {
args.push(x`{ ${attr_name}: true }`);
} else if (
@ -90,7 +90,7 @@ export default function (node: Element, renderer: Renderer, options: RenderOptio
const name = attribute.name.toLowerCase();
const attr_name = node.namespace === namespaces.foreign ? attribute.name : fix_attribute_casing(attribute.name);
if (name === 'value' && node.name.toLowerCase() === 'textarea') {
node_contents = get_attribute_value(attribute, true);
node_contents = get_attribute_value(attribute);
} else if (attribute.is_true) {
renderer.add_string(` ${attr_name}`);
} else if (

@ -16,12 +16,15 @@ export function get_class_attribute_value(attribute: Attribute): ESTreeExpressio
return get_attribute_value(attribute);
}
export function get_attribute_value(attribute: Attribute): ESTreeExpression {
if (attribute.chunks.length === 0) return x`""`;
/**
* For value attribute of textarea, it will render as child node of `<textarea>` element.
* Therefore, we need to escape as content (not attribute).
*/
export function get_attribute_value(attribute: Attribute, is_textarea_value = false): ESTreeExpression {
if (attribute.chunks.length === 0) return x`""`;
const is_textarea_value = attribute.parent.name.toLowerCase() === 'textarea' && attribute.name.toLowerCase() === 'value';
return attribute.chunks
.map((chunk) => {

Loading…
Cancel
Save