Module: DOM::Attributes
- Included in:
- Element
- Defined in:
- opal/fron/dom/modules/attributes.rb
Overview
Attributes
Instance Method Summary collapse
-
#[](name) ⇒ String
Returns the value of the attribute with the given name.
-
#[]=(name, value) ⇒ type
Sets the value of the attribute with the given name with the given value.
-
#attribute?(name) ⇒ Boolean
Returns if the element has the given attribute.
-
#remove_attribute(name) ⇒ Object
Removes the given attribute.
Instance Method Details
#[](name) ⇒ String
Returns the value of the attribute with the given name
9 10 11 |
# File 'opal/fron/dom/modules/attributes.rb', line 9 def [](name) `#{@el}.getAttribute(#{name}) || Opal.nil` end |
#[]=(name, value) ⇒ type
Sets the value of the attribute with the given name with the given value
19 20 21 22 23 24 25 |
# File 'opal/fron/dom/modules/attributes.rb', line 19 def []=(name, value) if value `#{@el}.setAttribute(#{name},#{value})` else remove_attribute name end end |
#attribute?(name) ⇒ Boolean
Returns if the element has the given attribute
32 33 34 |
# File 'opal/fron/dom/modules/attributes.rb', line 32 def attribute?(name) `#{@el}.hasAttribute(#{name})` end |
#remove_attribute(name) ⇒ Object
Removes the given attribute
39 40 41 |
# File 'opal/fron/dom/modules/attributes.rb', line 39 def remove_attribute(name) `#{@el}.removeAttribute(#{name})` end |