import deindent from '../../utils/deindent'; import { stringify, escapeHTML } from '../../utils/stringify'; import flattenReference from '../../utils/flattenReference'; import isVoidElementName from '../../utils/isVoidElementName'; import validCalleeObjects from '../../utils/validCalleeObjects'; import reservedNames from '../../utils/reservedNames'; import Node from './shared/Node'; import Block from '../dom/Block'; import Attribute from './Attribute'; import Binding from './Binding'; import EventHandler from './EventHandler'; import Ref from './Ref'; import Transition from './Transition'; import Text from './Text'; import * as namespaces from '../../utils/namespaces'; export default class Element extends Node { type: 'Element'; name: string; attributes: (Attribute | Binding | EventHandler | Ref | Transition)[]; // TODO split these up sooner children: Node[]; init( block: Block, stripWhitespace: boolean, nextSibling: Node ) { if (this.name === 'slot' || this.name === 'option') { this.cannotUseInnerHTML(); } const parentElement = this.parent && this.parent.findNearest(/^Element/); this.namespace = this.name === 'svg' ? namespaces.svg : parentElement ? parentElement.namespace : this.generator.namespace; this.attributes.forEach(attribute => { if (attribute.type === 'Attribute' && attribute.value !== true) { // special case — xmlns if (attribute.name === 'xmlns') { // TODO this attribute must be static – enforce at compile time this.namespace = attribute.value[0].data; } attribute.value.forEach((chunk: Node) => { if (chunk.type !== 'Text') { if (this.parent) this.parent.cannotUseInnerHTML(); const dependencies = chunk.metadata.dependencies; block.addDependencies(dependencies); // special case —