void HTMLConstructionSite::mergeAttributesFromTokenIntoElement(AtomicHTMLToken* token, Element* element) { if (token->attributes().isEmpty()) return; ElementAttributeData* elementAttributeData = element->mutableAttributeData(); for (unsigned i = 0; i < token->attributes().size(); ++i) { const Attribute& tokenAttribute = token->attributes().at(i); if (!elementAttributeData->getAttributeItem(tokenAttribute.name())) element->setAttribute(tokenAttribute.name(), tokenAttribute.value()); } }
void ElementAttributeData::setAttributes(const ElementAttributeData& other, Element* element) { ASSERT(element); // If assigning the map changes the id attribute, we need to call // updateId. Attribute* oldId = getAttributeItem(element->document()->idAttributeName()); Attribute* newId = other.getAttributeItem(element->document()->idAttributeName()); if (oldId || newId) element->updateId(oldId ? oldId->value() : nullAtom, newId ? newId->value() : nullAtom); Attribute* oldName = getAttributeItem(HTMLNames::nameAttr); Attribute* newName = other.getAttributeItem(HTMLNames::nameAttr); if (oldName || newName) element->updateName(oldName ? oldName->value() : nullAtom, newName ? newName->value() : nullAtom); clearAttributes(element); m_attributes = other.m_attributes; for (unsigned i = 0; i < m_attributes.size(); ++i) element->attributeChanged(&m_attributes[i]); }