Class HTMLCollection
java.lang.Object
org.htmlunit.corejs.javascript.ScriptableObject
org.htmlunit.javascript.HtmlUnitScriptable
org.htmlunit.javascript.host.dom.AbstractList
org.htmlunit.javascript.host.html.HTMLCollection
- All Implemented Interfaces:
Serializable,Cloneable,org.htmlunit.corejs.javascript.Callable,org.htmlunit.corejs.javascript.ConstProperties,org.htmlunit.corejs.javascript.debug.DebuggableObject,org.htmlunit.corejs.javascript.ExternalArrayData,org.htmlunit.corejs.javascript.Scriptable,org.htmlunit.corejs.javascript.SymbolScriptable
- Direct Known Subclasses:
HTMLAllCollection,HTMLCollectionFrames,HTMLFormControlsCollection
An array of elements. Used for the element arrays returned by
This class (like all classes in this package) is specific for the JavaScript engine. Users of HtmlUnit shouldn't use it directly.
document.all,
document.all.tags('x'), document.forms, window.frames, etc.
Note that this class must not be used for collections that can be modified, for example
map.areas and select.options.
This class (like all classes in this package) is specific for the JavaScript engine. Users of HtmlUnit shouldn't use it directly.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.htmlunit.javascript.host.dom.AbstractList
AbstractList.EffectOnCacheNested classes/interfaces inherited from class org.htmlunit.corejs.javascript.ScriptableObject
org.htmlunit.corejs.javascript.ScriptableObject.KeyComparator -
Field Summary
Fields inherited from class org.htmlunit.corejs.javascript.ScriptableObject
CONST, DONTENUM, EMPTY, PERMANENT, READONLY, UNINITIALIZED_CONSTFields inherited from interface org.htmlunit.corejs.javascript.Scriptable
NOT_FOUND -
Constructor Summary
ConstructorsModifierConstructorDescriptionCreates an instance.HTMLCollection(DomNode domNode, boolean attributeChangeSensitive) Creates an instance.privateHTMLCollection(DomNode domNode, boolean attributeChangeSensitive, List<DomNode> initialElements) (package private)HTMLCollection(DomNode domNode, List<DomNode> initialElements) Constructs an instance with an initial cache value. -
Method Summary
Modifier and TypeMethodDescriptioncall(org.htmlunit.corejs.javascript.Context cx, org.htmlunit.corejs.javascript.Scriptable scope, org.htmlunit.corejs.javascript.Scriptable thisObj, Object[] args) protected HTMLCollectionConstructs a new instance with an initial cache value.static HTMLCollectionemptyCollection(DomNode domNode) Gets an empty collection.final intReturns the length.protected ObjectgetWithPreemptionByName(String name, List<DomNode> elements) Helper forAbstractList.getWithPreemption(String)when finding by id doesn't get results.protected booleanReturns whetherAbstractList.getWithPreemption(String)should search by name or not.Returns the item or items corresponding to the specified index or key.org.htmlunit.corejs.javascript.Scriptableiterator()voidJavaScript constructor.Retrieves the item or items corresponding to the specified name (checks ids, and if that does not work, then names).protected booleanIs parentheses supported.Methods inherited from class org.htmlunit.javascript.host.dom.AbstractList
avoidObjectDetection, defineProperty, equivalentValues, getArrayElement, getArrayLength, getElements, getElementSupplier, getIsMatchingPredicate, getIt, getScriptableForElement, getWithPreemption, setArrayElement, setAvoidObjectDetection, setDomNode, setEffectOnCacheFunction, setElementsSupplier, setIsMatchingPredicate, toStringMethods inherited from class org.htmlunit.javascript.HtmlUnitScriptable
clone, get, getBrowserVersion, getClassName, getDefaultValue, getDomNodeOrDie, getDomNodeOrNull, getPrototype, getScriptableFor, getStartingScope, getWindow, getWindow, has, hasInstance, initParentScope, makeScriptableFor, put, setClassName, setDomNode, setParentScope, setupPromise, setupRejectedPromiseMethods inherited from class org.htmlunit.corejs.javascript.ScriptableObject
applyDescriptorToAttributeBitset, associateValue, buildDataDescriptor, callMethod, callMethod, checkPropertyChange, checkPropertyDefinition, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineFunctionProperties, defineOwnProperties, defineOwnProperty, defineOwnProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, delete, delete, delete, deleteProperty, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, ensureSymbolScriptable, get, get, get, getAllIds, getArrayPrototype, getAssociatedValue, getAttributes, getAttributes, getAttributes, getAttributes, getAttributes, getClassPrototype, getDefaultValue, getExternalArrayData, getExternalArrayLength, getFunctionPrototype, getGeneratorFunctionPrototype, getGetterOrSetter, getGetterOrSetter, getIds, getObjectPrototype, getOwnPropertyDescriptor, getParentScope, getProperty, getProperty, getProperty, getPropertyIds, getPrototype, getTopLevelScope, getTopScopeValue, getTypedProperty, getTypedProperty, getTypeOf, has, has, hasProperty, hasProperty, hasProperty, isAccessorDescriptor, isConst, isDataDescriptor, isEmpty, isExtensible, isFalse, isGenericDescriptor, isGetterOrSetter, isSealed, isTrue, preventExtensions, put, put, putConst, putConstProperty, putProperty, putProperty, putProperty, querySlot, redefineProperty, sameValue, sealObject, setAttributes, setAttributes, setAttributes, setAttributes, setAttributes, setCommonDescriptorProperties, setExternalArrayData, setGetterOrSetter, setPrototype, size
-
Constructor Details
-
HTMLCollection
public HTMLCollection()Creates an instance. -
HTMLCollection
Creates an instance.- Parameters:
domNode- parent scopeattributeChangeSensitive- indicates if the content of the collection may change when an attribute of a descendant node of parentScope changes (attribute added, modified or removed)
-
HTMLCollection
Constructs an instance with an initial cache value.- Parameters:
domNode- the parent scope, on which we listen for changesinitialElements- the initial content for the cache
-
HTMLCollection
-
-
Method Details
-
jsConstructor
public void jsConstructor()JavaScript constructor. -
emptyCollection
Gets an empty collection.- Parameters:
domNode- the DOM node- Returns:
- an empty collection
-
create
Constructs a new instance with an initial cache value.- Overrides:
createin classAbstractList- Parameters:
parentScope- the parent scope, on which we listen for changesinitialElements- the initial content for the cache- Returns:
- the newly created instance
-
iterator
public org.htmlunit.corejs.javascript.Scriptable iterator() -
getLength
public final int getLength()Returns the length.- Overrides:
getLengthin classAbstractList- Returns:
- the length
-
call
public Object call(org.htmlunit.corejs.javascript.Context cx, org.htmlunit.corejs.javascript.Scriptable scope, org.htmlunit.corejs.javascript.Scriptable thisObj, Object[] args) - Specified by:
callin interfaceorg.htmlunit.corejs.javascript.Callable
-
supportsParentheses
protected boolean supportsParentheses()Is parentheses supported.- Returns:
- true or false
-
getWithPreemptionByName
Helper forAbstractList.getWithPreemption(String)when finding by id doesn't get results.- Overrides:
getWithPreemptionByNamein classAbstractList- Parameters:
name- the property nameelements- the children elements.- Returns:
Scriptable.NOT_FOUNDif not found
-
isGetWithPreemptionSearchName
protected boolean isGetWithPreemptionSearchName()Returns whetherAbstractList.getWithPreemption(String)should search by name or not.- Returns:
- whether
AbstractList.getWithPreemption(String)should search by name or not
-
item
Returns the item or items corresponding to the specified index or key.- Parameters:
index- the index or key corresponding to the element or elements to return- Returns:
- the element or elements corresponding to the specified index or key
- See Also:
-
namedItem
Retrieves the item or items corresponding to the specified name (checks ids, and if that does not work, then names).- Parameters:
name- the name or id the element or elements to return- Returns:
- the element or elements corresponding to the specified name or id
- See Also:
-