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 fixAttributeCasing from '../../utils/fixAttributeCasing'; import { quoteNameIfNecessary, quotePropIfNecessary } from '../../utils/quoteIfNecessary'; import Compiler from '../Compiler'; import Node from './shared/Node'; import Block from '../dom/Block'; import Attribute from './Attribute'; import Binding from './Binding'; import EventHandler from './EventHandler'; import Transition from './Transition'; import Animation from './Animation'; import Action from './Action'; import Text from './Text'; import * as namespaces from '../../utils/namespaces'; import mapChildren from './shared/mapChildren'; import { dimensions } from '../../utils/patterns'; // source: https://gist.github.com/ArjanSchouten/0b8574a6ad7f5065a5e7 const booleanAttributes = new Set([ 'async', 'autocomplete', 'autofocus', 'autoplay', 'border', 'challenge', 'checked', 'compact', 'contenteditable', 'controls', 'default', 'defer', 'disabled', 'formnovalidate', 'frameborder', 'hidden', 'indeterminate', 'ismap', 'loop', 'multiple', 'muted', 'nohref', 'noresize', 'noshade', 'novalidate', 'nowrap', 'open', 'readonly', 'required', 'reversed', 'scoped', 'scrolling', 'seamless', 'selected', 'sortable', 'spellcheck', 'translate' ]); export default class Element extends Node { type: 'Element'; name: string; scope: any; // TODO attributes: Attribute[]; actions: Action[]; bindings: Binding[]; handlers: EventHandler[]; intro?: Transition; outro?: Transition; animation?: Animation; children: Node[]; ref: string; namespace: string; constructor(compiler, parent, scope, info: any) { super(compiler, parent, scope, info); this.name = info.name; this.scope = scope; const parentElement = parent.findNearest(/^Element/); this.namespace = this.name === 'svg' ? namespaces.svg : parentElement ? parentElement.namespace : this.compiler.namespace; this.attributes = []; this.actions = []; this.bindings = []; this.handlers = []; this.intro = null; this.outro = null; this.animation = null; if (this.name === 'textarea') { // this is an egregious hack, but it's the easiest way to get