HtmlElementProperties class
The dynamic property bag on an HtmlElement. Reached through HtmlElement.Properties. Every CSS property, every DOM attribute, every custom-widget extension is accessed through this bag — and almost always written in shorthand because Properties is the DefaultMember of HtmlElement:
With element ' element.Properties is the default member
.style.display = "flex" ' Properties.Item("style").Item("display").Value = "flex"
.style.flexDirection = "column"
.style.gap = "10px"
.innerText = "Hello"
End With
The shorthand reads at run time as a chain of Item("name") lookups against the underlying DOM element — see Dynamic DOM property resolution on the package overview.
Important
This interface is [COMExtensible(True)]. Property names are resolved against the live DOM element at run time, not declared statically on the interface. The compiler does not validate names — a typo (.innerTxt = "..." instead of .innerText = "...") fails silently or throws at run time. The accepted set is every DOM property of the underlying tag, plus any custom-widget extensions; the reference does not enumerate it.
Note
A property whose name starts with on is ignored. In BETA 995, .onclick = "..." sets nothing, and the call returns without an error. Register a listener with HtmlElement.AddEventListener instead.
Important
Text set as innerHTML is parsed as HTML, and an inline event handler in it runs as script of the IDE’s own page, with access to everything that page’s script can reach. An <img> whose image fails to load runs its onerror handler as soon as it is set, with nothing clicked. Escape any text that comes from a file, a project or the user before it goes into innerHTML, or set innerText instead.
Default member
The interface’s DefaultMember is Item — so properties("style") is equivalent to properties.Item("style"). Chains of .style.color = "red" thus desugar to properties.Item("style").Item("color").Value = "red".
Properties
Item
Looks up a property by name. Returns an HtmlElementProperty, which includes the property’s value plus a nested Properties for further drill-down.
Syntax: properties( DomPropertyName ) As HtmlElementProperty
- DomPropertyName
- required The property name. String. Standard DOM property names, CSS-style property names (when looked up under
style), or custom-widget property names — all forwarded to the IDE’s tool-window renderer.