import attributeLookup from './lookup.js'; import addElementBinding from './addElementBinding'; import deindent from '../../../../utils/deindent.js'; import flattenReference from '../../../../utils/flattenReference.js'; import getStaticAttributeValue from './binding/getStaticAttributeValue.js'; export default function addElementAttributes ( generator, node, local ) { node.attributes.forEach( attribute => { const name = attribute.name; if ( attribute.type === 'Attribute' ) { let metadata = local.namespace ? null : attributeLookup[ name ]; if ( metadata && metadata.appliesTo && !~metadata.appliesTo.indexOf( node.name ) ) metadata = null; let dynamic = false; const isIndirectlyBoundValue = name === 'value' && ( node.name === 'option' || // TODO check it's actually bound node.name === 'input' && /^(checkbox|radio)$/.test( getStaticAttributeValue( node, 'type' ) ) ); const propertyName = isIndirectlyBoundValue ? '__value' : metadata && metadata.propertyName; const isXlink = name.slice( 0, 6 ) === 'xlink:'; // xlink is a special case... we could maybe extend this to generic // namespaced attributes but I'm not sure that's applicable in // HTML5? const method = isXlink ? 'setXlinkAttribute' : 'setAttribute'; if ( attribute.value === true ) { // attributes without values, e.g.