Style
@Js
class Style : Obj
Style models CSS style properties for an Elem.
The CSS classes for this element
Add the given CSS class name to this element
Add a psuedo-class CSS definietion to this element
Clear all style declarations
Get the computed property value
Get the effetive style property value, which is the most specific style or CSS rule in effect on this node
Get the given property value
Return true if this element has the given CSS class name, or false if it does not
Remove the given CSS class name to this element
Set the given propery value
Set all the given property values
Set properties via CSS text
Toggle the presence of the given CSS class name based on
the cond argument
Get or set an attribute
This addClass(Str name)
Add the given CSS class name to this element. If this element already contains the given class name, then this method does nothing. Returns this.
Str addPseudoClass(Str name, Str css)
Add a psuedo-class CSS definietion to this element. A new
class name is auto-generated and used to prefix name,
name must start with the : character. Returns the
generated class name.
style.addPseudoClass(":hover", "background: #eee")
Str[] : classes
The CSS classes for this element.
This clear()
Clear all style declarations.
Obj? computed(Str name)
Get the computed property value.
Obj? effective(Str name)
Get the effetive style property value, which is the most
specific style or CSS rule in effect on this node. Returns
null if no rule in effect for given property.
This method is restricted to stylesheets that have originated from the same domain as the document. Any rules that may be applied from an external sheet will not be included.
@Operator
Obj? get(Str name)
Get the given property value.
color := style["color"]
Bool hasClass(Str name)
Return true if this element has the given CSS class name, or false if it does not.
This removeClass(Str name)
Remove the given CSS class name to this element. If this element does not have the given class name, this method does nothing. Returns this.
@Operator
This set(Str name, Obj? val)
Set the given propery value. If val is null this
property is removed.
style["color"] = "#f00"
This setAll(Str:Obj? map)
Set all the given property values.
style.setAll(["color":"#f00", "font-weight":"bold"])
This setCss(Str css)
Set properties via CSS text.
style.setCss("color: #f00; font-weight: bold;")
This toggleClass(Str name, Bool? cond := null)
Toggle the presence of the given CSS class name based on
the cond argument:
null: remove class if present, or add if missingtrue: always add class (see addClass)false: always remove class(see removeClass)
virtual Obj? trap(Str name, Obj?[]? args := null)
Get or set an attribute. Attribute names should be specifed in camel case:
style->backgroundColor == style["background-color"]