@Override public String toString() { if (toString == null) { StringBuilder sb = new StringBuilder(); sb.append('<').append(element.getTagName()); NamedNodeMap attributes = element.getAttributes(); int n = attributes.getLength(); for (int i = 0; i < n; ++i) { Attr a = (Attr) attributes.item(i); sb.append(' ').append(a.getName()).append("=\"") .append(a.getValue().replace("\"", """)).append("\""); } if (element.hasChildNodes()) { sb.append('>'); } else { sb.append(" />"); } toString = sb.toString(); } return toString; }
private static void copyAttributes(final DomElement to, final XMLAttributes attrs) { final int length = attrs.getLength(); for (int i = 0; i < length; i++) { final String attrName = attrs.getLocalName(i).toLowerCase(Locale.ROOT); if (to.getAttributes().getNamedItem(attrName) == null) { to.setAttribute(attrName, attrs.getValue(i)); if (attrName.startsWith("on") && to.getScriptableObject() instanceof HTMLBodyElement) { final HTMLBodyElement jsBody = to.getScriptableObject(); jsBody.createEventHandlerFromAttribute(attrName, attrs.getValue(i)); } } } }
/** * Creates a new named node map for the specified element. * * @param element the owning element */ public NamedNodeMap(final DomElement element) { setParentScope(element.getScriptObject()); setPrototype(getPrototype(getClass())); attributes_ = element.getAttributes(); setDomNode(element, false); }
/** * Creates a new named node map for the specified element. * * @param element the owning element */ public NamedNodeMap(final DomElement element) { setParentScope(element.getScriptObject()); setPrototype(getPrototype(getClass())); attributes_ = element.getAttributes(); setDomNode(element, false); }
private void updateAttribute(final String value) { final DomElement domNode = (DomElement) getDomNodeOrDie(); DomAttr attr = (DomAttr) domNode.getAttributes().getNamedItem(attributeName_); if (null == attr) { attr = domNode.getPage().createAttribute(attributeName_); domNode.setAttributeNode(attr); } attr.setValue(value); }
/** * Creates a new named node map for the specified element. * * @param element the owning element */ public NamedNodeMap(final DomElement element) { setParentScope(element.getScriptableObject()); setPrototype(getPrototype(getClass())); attributes_ = element.getAttributes(); setDomNode(element, false); }
private void updateAttribute(final String value) { final DomElement domNode = (DomElement) getDomNodeOrDie(); DomAttr attr = (DomAttr) domNode.getAttributes().getNamedItem(attributeName_); if (null == attr) { attr = domNode.getPage().createAttribute(attributeName_); domNode.setAttributeNode(attr); } attr.setValue(value); }
/** * Creates a new named node map for the specified element. * * @param element the owning element */ public NamedNodeMap(final DomElement element) { setParentScope(element.getScriptObject()); setPrototype(getPrototype(getClass())); attributes_ = element.getAttributes(); setDomNode(element, false); }
/** * Creates a new named node map for the specified element. * * @param element the owning element */ public NamedNodeMap(final DomElement element) { setParentScope(element.getScriptableObject()); setPrototype(getPrototype(getClass())); attributes_ = element.getAttributes(); setDomNode(element, false); }
private static void copyAttributes(final DomElement to, final XMLAttributes attrs) { final int length = attrs.getLength(); for (int i = 0; i < length; i++) { final String attrName = attrs.getLocalName(i).toLowerCase(Locale.ROOT); if (to.getAttributes().getNamedItem(attrName) == null) { to.setAttribute(attrName, attrs.getValue(i)); if (attrName.startsWith("on") && to.getScriptableObject() instanceof HTMLBodyElement) { final HTMLBodyElement jsBody = to.getScriptableObject(); jsBody.createEventHandlerFromAttribute(attrName, attrs.getValue(i)); } } } }