|
|
@ -2,12 +2,12 @@ import Renderer from '../../Renderer';
|
|
|
|
import Element from '../../../nodes/Element';
|
|
|
|
import Element from '../../../nodes/Element';
|
|
|
|
import Wrapper from '../shared/Wrapper';
|
|
|
|
import Wrapper from '../shared/Wrapper';
|
|
|
|
import Block from '../../Block';
|
|
|
|
import Block from '../../Block';
|
|
|
|
import { is_void, quote_prop_if_necessary, quote_name_if_necessary, sanitize } from '../../../../utils/names';
|
|
|
|
import { is_void, sanitize } from '../../../../utils/names';
|
|
|
|
import FragmentWrapper from '../Fragment';
|
|
|
|
import FragmentWrapper from '../Fragment';
|
|
|
|
import { escape_html, string_literal } from '../../../utils/stringify';
|
|
|
|
import { escape_html, string_literal } from '../../../utils/stringify';
|
|
|
|
import TextWrapper from '../Text';
|
|
|
|
import TextWrapper from '../Text';
|
|
|
|
import fix_attribute_casing from './fix_attribute_casing';
|
|
|
|
import fix_attribute_casing from './fix_attribute_casing';
|
|
|
|
import { b, x } from 'code-red';
|
|
|
|
import { b, x, p } from 'code-red';
|
|
|
|
import { namespaces } from '../../../../utils/namespaces';
|
|
|
|
import { namespaces } from '../../../../utils/namespaces';
|
|
|
|
import AttributeWrapper from './Attribute';
|
|
|
|
import AttributeWrapper from './Attribute';
|
|
|
|
import StyleAttributeWrapper from './StyleAttribute';
|
|
|
|
import StyleAttributeWrapper from './StyleAttribute';
|
|
|
@ -381,8 +381,7 @@ export default class ElementWrapper extends Wrapper {
|
|
|
|
get_claim_statement(nodes: Identifier) {
|
|
|
|
get_claim_statement(nodes: Identifier) {
|
|
|
|
const attributes = this.node.attributes
|
|
|
|
const attributes = this.node.attributes
|
|
|
|
.filter((attr) => attr.type === 'Attribute')
|
|
|
|
.filter((attr) => attr.type === 'Attribute')
|
|
|
|
.map((attr) => `${quote_name_if_necessary(attr.name)}: true`)
|
|
|
|
.map((attr) => p`${attr.name}: true`);
|
|
|
|
.join(', ');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const name = this.node.namespace
|
|
|
|
const name = this.node.namespace
|
|
|
|
? this.node.name
|
|
|
|
? this.node.name
|
|
|
@ -603,7 +602,7 @@ export default class ElementWrapper extends Wrapper {
|
|
|
|
|
|
|
|
|
|
|
|
updates.push(condition ? x`${condition} && ${snippet}` : snippet);
|
|
|
|
updates.push(condition ? x`${condition} && ${snippet}` : snippet);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
const snippet = x`{ ${quote_name_if_necessary(attr.name)}: ${attr.get_value(block)} }`;
|
|
|
|
const snippet = x`{ ${attr.name}: ${attr.get_value(block)} }`;
|
|
|
|
initial_props.push(snippet);
|
|
|
|
initial_props.push(snippet);
|
|
|
|
|
|
|
|
|
|
|
|
updates.push(condition ? x`${condition} && ${snippet}` : snippet);
|
|
|
|
updates.push(condition ? x`${condition} && ${snippet}` : snippet);
|
|
|
@ -813,7 +812,7 @@ export default class ElementWrapper extends Wrapper {
|
|
|
|
snippet = expression.manipulate(block);
|
|
|
|
snippet = expression.manipulate(block);
|
|
|
|
dependencies = expression.dependencies;
|
|
|
|
dependencies = expression.dependencies;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
snippet = `${quote_prop_if_necessary(name)}`;
|
|
|
|
snippet = name;
|
|
|
|
dependencies = new Set([name]);
|
|
|
|
dependencies = new Set([name]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const updater = b`@toggle_class(${this.var}, "${name}", ${snippet});`;
|
|
|
|
const updater = b`@toggle_class(${this.var}, "${name}", ${snippet});`;
|
|
|
|