/** * Adds an attribute to the specified attribute map. This is just used by the element factories. * @param page the page which contains the attribute being created * @param attributeMap the attribute map where the attribute will be added * @param namespaceURI the URI that identifies an XML namespace * @param qualifiedName the qualified name of the attribute * @param value the value of the attribute * @return the new attribute which was added to the specified attribute map */ static DomAttr addAttributeToMap(final SgmlPage page, final Map<String, DomAttr> attributeMap, final String namespaceURI, final String qualifiedName, final String value) { final DomAttr newAttr = new DomAttr(page, namespaceURI, qualifiedName, value); attributeMap.put(qualifiedName, newAttr); return newAttr; }
/** * Adds an attribute to the specified attribute map. This is just used by the element factories. * @param page the page which contains the attribute being created * @param attributeMap the attribute map where the attribute will be added * @param namespaceURI the URI that identifies an XML namespace * @param qualifiedName the qualified name of the attribute * @param value the value of the attribute * @return the new attribute which was added to the specified attribute map */ static DomAttr addAttributeToMap(final SgmlPage page, final Map<String, DomAttr> attributeMap, final String namespaceURI, final String qualifiedName, final String value) { final DomAttr newAttr = new DomAttr(page, namespaceURI, qualifiedName, value); attributeMap.put(qualifiedName, newAttr); return newAttr; }
/** * Adds an attribute to the specified attribute map. This is just used by the element factories. * @param page the page which contains the attribute being created * @param attributeMap the attribute map where the attribute will be added * @param namespaceURI the URI that identifies an XML namespace * @param qualifiedName the qualified name of the attribute * @param value the value of the attribute * @return the new attribute which was added to the specified attribute map */ static DomAttr addAttributeToMap(final SgmlPage page, final Map<String, DomAttr> attributeMap, final String namespaceURI, final String qualifiedName, final String value) { final DomAttr newAttr = new DomAttr(page, namespaceURI, qualifiedName, value); attributeMap.put(qualifiedName, newAttr); return newAttr; }
/** * Add missing attribute if needed by fixing attribute map rather to add it afterwards as this second option * triggers the instantiation of the script object at a time where the DOM node has not yet been added to its * parent. */ private static Map<String, DomAttr> addValueIfNeeded(final SgmlPage page, final Map<String, DomAttr> attributes) { for (final String key : attributes.keySet()) { if ("value".equalsIgnoreCase(key)) { return attributes; // value attribute was specified } } // value attribute was not specified, add it final DomAttr newAttr = new DomAttr(page, null, "value", DEFAULT_VALUE, true); attributes.put("value", newAttr); return attributes; }
/** * Add missing attribute if needed by fixing attribute map rather to add it afterwards as this second option * triggers the instantiation of the script object at a time where the DOM node has not yet been added to its * parent. */ private static Map<String, DomAttr> addValueIfNeeded(final SgmlPage page, final Map<String, DomAttr> attributes) { for (final String key : attributes.keySet()) { if ("value".equalsIgnoreCase(key)) { return attributes; // value attribute was specified } } // value attribute was not specified, add it final DomAttr newAttr = new DomAttr(page, null, "value", DEFAULT_VALUE, true); attributes.put("value", newAttr); return attributes; }
/** * Add missing attribute if needed by fixing attribute map rather to add it afterwards as this second option * triggers the instantiation of the script object at a time where the DOM node has not yet been added to its * parent. */ private static Map<String, DomAttr> addValueIfNeeded(final SgmlPage page, final Map<String, DomAttr> attributes) { for (final String key : attributes.keySet()) { if ("value".equalsIgnoreCase(key)) { return attributes; // value attribute was specified } } // value attribute was not specified, add it final DomAttr newAttr = new DomAttr(page, null, "value", DEFAULT_VALUE, true); attributes.put("value", newAttr); return attributes; }
/** * Add missing attribute if needed by fixing attribute map rather to add it afterwards as this second option * triggers the instantiation of the script object at a time where the DOM node has not yet been added to its * parent. */ private static Map<String, DomAttr> addValueIfNeeded(final SgmlPage page, final Map<String, DomAttr> attributes) { for (final String key : attributes.keySet()) { if ("value".equalsIgnoreCase(key)) { return attributes; // value attribute was specified } } // value attribute was not specified, add it final DomAttr newAttr = new DomAttr(page, null, "value", DEFAULT_VALUE, true); attributes.put("value", newAttr); return attributes; }
/** * {@inheritDoc} */ @Override public DomAttr createAttribute(final String name) { return new DomAttr(getPage(), null, name, "", false); }
/** * {@inheritDoc} */ @Override public DomAttr createAttribute(final String name) { return new DomAttr(getPage(), null, name, "", false); }
private static Map<String, DomAttr> toMap(final SgmlPage page, final Attributes attributes) { Map<String, DomAttr> attributeMap = null; if (attributes != null) { attributeMap = new LinkedHashMap<>(attributes.getLength()); for (int i = 0; i < attributes.getLength(); i++) { final String qName = attributes.getQName(i); // browsers consider only first attribute (ex: <div id='foo' id='something'>...</div>) if (!attributeMap.containsKey(qName)) { String namespaceURI = attributes.getURI(i); if (namespaceURI != null && namespaceURI.isEmpty()) { namespaceURI = null; } final DomAttr newAttr = new DomAttr(page, namespaceURI, qName, attributes.getValue(i), true); attributeMap.put(qName, newAttr); } } } return attributeMap; }
/** * Creates a new HTML attribute with the specified name. * * @param attributeName the name of the attribute to create * @return an attribute with the specified name */ public Attr jsxFunction_createAttribute(final String attributeName) { final DomAttr attr = new DomAttr(getPage(), null, attributeName, null); return (Attr) attr.getScriptObject(); }
/** * Creates a new HTML attribute with the specified name. * * @param attributeName the name of the attribute to create * @return an attribute with the specified name */ public Attr jsxFunction_createAttribute(final String attributeName) { final DomAttr attr = new DomAttr(getPage(), null, attributeName, null); return (Attr) attr.getScriptObject(); }
/** * Creates a new HTML attribute with the specified name. * * @param attributeName the name of the attribute to create * @return an attribute with the specified name */ public Attr jsxFunction_createAttribute(final String attributeName) { final DomAttr attr = new DomAttr(getPage(), null, attributeName, null); return (Attr) attr.getScriptObject(); }
/** * Add missing attribute if needed by fixing attribute map rather to add it afterwards as this second option * triggers the instantiation of the script object at a time where the DOM node has not yet been added to its * parent. */ private static Map<String, DomAttr> addValueIfNeeded(final SgmlPage page, final Map<String, DomAttr> attributes) { final BrowserVersion browserVersion = page.getWebClient().getBrowserVersion(); if (browserVersion.hasFeature(RESETINPUT_DEFAULT_VALUE_IF_VALUE_NOT_DEFINED)) { for (final String key : attributes.keySet()) { if ("value".equalsIgnoreCase(key)) { return attributes; // value attribute was specified } } // value attribute was not specified, add it final DomAttr newAttr = new DomAttr(page, null, "value", DEFAULT_VALUE, true); attributes.put("value", newAttr); } return attributes; }
/** * Add missing attribute if needed by fixing attribute map rather to add it afterwards as this second option * triggers the instantiation of the script object at a time where the DOM node has not yet been added to its * parent. */ private static Map<String, DomAttr> addValueIfNeeded(final SgmlPage page, final Map<String, DomAttr> attributes) { final BrowserVersion browserVersion = page.getWebClient().getBrowserVersion(); if (browserVersion.hasFeature(SUBMITINPUT_DEFAULT_VALUE_IF_VALUE_NOT_DEFINED)) { for (final String key : attributes.keySet()) { if ("value".equalsIgnoreCase(key)) { return attributes; // value attribute was specified } } // value attribute was not specified, add it final DomAttr newAttr = new DomAttr(page, null, "value", DEFAULT_VALUE, true); attributes.put("value", newAttr); } return attributes; }
private static Map<String, DomAttr> createAttributesCopyWithClonedAttribute(final HtmlElement elt, final String attrName) { final Map<String, DomAttr> newMap = new HashMap<>(elt.getAttributesMap()); // clone the specified element, if possible final DomAttr attr = newMap.get(attrName); if (null == attr) { return newMap; } final DomAttr clonedAttr = new DomAttr(attr.getPage(), attr.getNamespaceURI(), attr.getQualifiedName(), attr.getValue(), attr.getSpecified()); newMap.put(attrName, clonedAttr); return newMap; }
private static Map<String, DomAttr> createAttributesCopyWithClonedAttribute(final HtmlElement elt, final String attrName) { final Map<String, DomAttr> newMap = new HashMap<>(elt.getAttributesMap()); // clone the specified element, if possible final DomAttr attr = newMap.get(attrName); if (null == attr) { return newMap; } final DomAttr clonedAttr = new DomAttr(attr.getPage(), attr.getNamespaceURI(), attr.getQualifiedName(), attr.getValue(), attr.getSpecified()); newMap.put(attrName, clonedAttr); return newMap; }
/** * Sets the value of the attribute specified by namespace and qualified name. * * @param namespaceURI the URI that identifies an XML namespace * @param qualifiedName the qualified name (prefix:local) of the attribute * @param attributeValue the value of the attribute * @param notifyAttributeChangeListeners to notify the associated {@link HtmlAttributeChangeListener}s * @param notifyMutationObservers to notify {@code MutationObserver}s or not */ protected void setAttributeNS(final String namespaceURI, final String qualifiedName, final String attributeValue, final boolean notifyAttributeChangeListeners, final boolean notifyMutationObservers) { final String value = attributeValue; final DomAttr newAttr = new DomAttr(getPage(), namespaceURI, qualifiedName, value, true); newAttr.setParentNode(this); attributes_.put(qualifiedName, newAttr); if (namespaceURI != null) { namespaces_.put(namespaceURI, newAttr.getPrefix()); } }
/** * Sets the value of the attribute specified by namespace and qualified name. * * @param namespaceURI the URI that identifies an XML namespace * @param qualifiedName the qualified name (prefix:local) of the attribute * @param attributeValue the value of the attribute */ public void setAttributeNS(final String namespaceURI, final String qualifiedName, final String attributeValue) { final String value = attributeValue; if (attributes_ == NamedAttrNodeMapImpl.EMPTY_MAP) { attributes_ = new NamedAttrNodeMapImpl(this, isAttributeCaseSensitive()); } final DomAttr newAttr = new DomAttr(getPage(), namespaceURI, qualifiedName, value); newAttr.setParentNode(this); attributes_.put(qualifiedName, newAttr); if (namespaceURI != null) { namespaces().put(namespaceURI, newAttr.getPrefix()); } }
/** * Sets the value of the attribute specified by namespace and qualified name. * * @param namespaceURI the URI that identifies an XML namespace * @param qualifiedName the qualified name (prefix:local) of the attribute * @param attributeValue the value of the attribute */ public void setAttributeNS(final String namespaceURI, final String qualifiedName, final String attributeValue) { final String value = attributeValue; if (attributes_ == NamedAttrNodeMapImpl.EMPTY_MAP) { attributes_ = new NamedAttrNodeMapImpl(this, isAttributeCaseSensitive()); } final DomAttr newAttr = new DomAttr(getPage(), namespaceURI, qualifiedName, value); newAttr.setParentNode(this); attributes_.put(qualifiedName, newAttr); if (namespaceURI != null) { namespaces().put(namespaceURI, newAttr.getPrefix()); } }