Class: Element

Inherits:
Object show all
Includes:
CodeEvents, Situated::Element, UserEvents
Defined in:
lib/source/redshift/element.rb,
lib/source/redshift/situated.rb,
lib/source/redshift/accessors.rb

Overview

Element objects represent DOM elements from the browser.

Defined Under Namespace

Classes: Classes, Properties, Styles

Constant Summary

Constants included from UserEvents

UserEvents::DEFINED_EVENTS, UserEvents::NATIVE_EVENTS

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Situated::Element

#offset_parent, #offsets, #position, #position_at, #scroll, #scroll_size, #scroll_to, #scrolls, #size

Methods included from Situated::PositionAndSize

#height, #left, #scroll_height, #scroll_left, #scroll_top, #scroll_width, #top, #width

Methods included from CodeEvents

#fire, #ignore, #upon

Methods included from UserEvents

#add_listener, define, extended, included, #listen, #remove_listener, #unlisten

Constructor Details

#initialize(tag, attributes = {}) ⇒ Element

call-seq:

Element.new(sym, attributes = {}) -> element

Returns a new Element with the tag sym and the given attributes.

Element.new(:div, :id => 'my_div', :class => 'inserted')    #=> #<Element: DIV id="my_div" class="inserted">


38
39
40
41
42
# File 'lib/source/redshift/element.rb', line 38

def initialize(tag, attributes = {})
  `if(!tag){return nil;}`
  `this.__native__ = document.createElement(tag.__value__)`
  self.set_properties(attributes)
end

Class Method Details

.destroy(elem) ⇒ Object

:nodoc:



14
15
16
17
18
19
# File 'lib/source/redshift/element.rb', line 14

def self.destroy(elem) # :nodoc:
  `var el = elem.__native__ || elem`
  `c$Element.m$empty(el)`
  `c$Element.m$remove(el)`
  return true
end

.empty(elem) ⇒ Object

:nodoc:



21
22
23
24
# File 'lib/source/redshift/element.rb', line 21

def self.empty(elem) # :nodoc:
  `for (var c=(elem.__native__||elem).childNodes,i=c.length;i>0;){c$Element.m$destroy(c[--i]);};`
  return true
end

.remove(elem) ⇒ Object

:nodoc:



26
27
28
29
# File 'lib/source/redshift/element.rb', line 26

def self.remove(elem) # :nodoc:
  `var el = elem.__native__ || elem`
  `(el.parentNode) ? el.parentNode.removeChild(el) : this`
end

Instance Method Details

#==(elem) ⇒ Object

:nodoc:



44
45
46
# File 'lib/source/redshift/element.rb', line 44

def ==(elem) # :nodoc:
  `this.__native__ === elem.__native__`
end

#===(elem) ⇒ Object

:nodoc:



48
49
50
# File 'lib/source/redshift/element.rb', line 48

def ===(elem) # :nodoc:
  `this.__native__ === elem.__native__`
end

#[](expression, *args) ⇒ Object

call-seq:

elem[str] -> array

*args?



57
58
59
60
61
62
63
64
65
66
67
# File 'lib/source/redshift/element.rb', line 57

def [](expression, *args)
  `if (expression.__value__.match(/^#[a-zA-z_]*$/) && #{args.empty?}){return #{self}.__native__.getElementById(expression.__value__.replace('#',''));}`
  expression = expression.split(',')
  items = []
  `for (var i = 0, l = expression.length, local = {}; i < l; i++){
    var selector = expression[i].__value__, elements = Selectors.Utils.search(#{self}.__native__, selector, local);
    elements = Array.fromCollection(elements);
    items = (i == 0) ? elements : items.concat(elements);     
  }`
  return items
end

#add_class(sym) ⇒ Object

call-seq:

elem.add_class(sym) -> elem

Returns elem with class name sym added.



14
15
16
17
# File 'lib/source/redshift/accessors.rb', line 14

def add_class(sym)
  `if(!this.m$has_class_bool(sym)){var el=this.__native__,c=el.className,s=sym.__value__;el.className=(c.length>0)?c+' '+s:s;}`
  return self
end

#add_classes(*args) ⇒ Object

call-seq:

elem.add_classes(sym, ...) -> elem

Calls elem.add_class(sym) once for each argument.



26
27
28
29
# File 'lib/source/redshift/accessors.rb', line 26

def add_classes(*args)
  args.each {|x| self.add_class(x) }
  return self
end

#children(match_selector = nil) ⇒ Object

call-seq:

elem.children -> array

Returns the array of elem’s child elements on the DOM tree.

<div id="container">
  <div id="a_element"></div>
    <div id="a_inner_element"></div>
  </div>
  <div id="b_element"></div>
</div>

Document['#container'].children   #=> [#<Element: DIV id="a_element">, #<Element: DIV id="b_element">]


83
84
85
# File 'lib/source/redshift/element.rb', line 83

def children(match_selector = nil)
  Document.walk(self, 'nextSibling', 'firstChild', match_selector, true)
end

#classObject

call-seq:

elem.class -> string

Returns a string representation of elem’s class names, separated by “ ”.



38
39
40
# File 'lib/source/redshift/accessors.rb', line 38

def class
  `$q(this.__native__.className)`
end

#class=(str) ⇒ Object

call-seq:

elem.class = str -> str

Sets elem’s HTML class property to str, which consists of one or many class names separated by “ ”.



50
51
52
53
# File 'lib/source/redshift/accessors.rb', line 50

def class=(str)
  `this.__native__.className=str.__value__`
  return str
end

#classesObject

call-seq:

elem.classes -> object

Returns an Element::Classes accessor object, which represents the classes assigned to elem, and allows for operations such as elem.classes << :klass, elem.classes.include? :klass, and elem.classes.toggle(:klass).



65
66
67
# File 'lib/source/redshift/accessors.rb', line 65

def classes
  @class_list ||= Element::Classes.new(self)
end

#classes=(ary) ⇒ Object

call-seq:

elem.classes = [sym, ...] -> array

Sets elem’s HTML class property to a string equivalent to the concatenation of each of the classes in array joined by “ ”, then returns array.



78
79
80
81
82
# File 'lib/source/redshift/accessors.rb', line 78

def classes=(ary)
  `for(var result=[],i=0,l=ary.length;i<l;++i){result.push(ary[i].__value__);}`
  `this.__native__.className=result.join(' ')`
  return ary
end

#clear_stylesObject

call-seq:

elem.clear_styles -> elem

Removes the CSS styles that have been applied to elem.



91
92
93
94
# File 'lib/source/redshift/accessors.rb', line 91

def clear_styles
  `this.__native__.style.cssText=''`
  return self
end

#destroy!Object

call-seq:

elem.destroy! -> true

Removes elem and all its children from the page and from the DOM, then returns true.



97
98
99
100
# File 'lib/source/redshift/element.rb', line 97

def destroy!
  Element.destroy(self)
  return true
end

#documentObject

:nodoc:



102
103
104
# File 'lib/source/redshift/element.rb', line 102

def document # :nodoc:
  `this.__native__.ownerDocument`
end

#empty!Object

call-seq:

elem.empty! -> true or false

Removes elem’s inner text and child elements from the page.



111
112
113
114
# File 'lib/source/redshift/element.rb', line 111

def empty!
  Element.empty(self)
  return self
end

#eql?(elem) ⇒ Boolean

:nodoc:

Returns:

  • (Boolean)


116
117
118
# File 'lib/source/redshift/element.rb', line 116

def eql?(elem) # :nodoc:
  `this.__native__ === elem.__native__`
end

#first_child(match_selector = nil) ⇒ Object

call-seq:

elem.first_child -> element

Returns the first child element of elem on the DOM tree, or nil if no such element is found.

<div id="container">
  <div id="a_element"></div>
  <div id="b_element"></div>
  <div id="c_element"></div>
  <div id="d_element"></div>
</div>

Document['#container'].first_child #=> #<Element: DIV id="a_element">


135
136
137
# File 'lib/source/redshift/element.rb', line 135

def first_child(match_selector = nil)
  Document.walk(self, 'nextSibling', 'firstChild', match_selector, false)
end

#get_property(attribute) ⇒ Object

call-seq:

elem.get_property(sym) -> object or nil

Returns the value of elem’s property sym, or nil if no value is set.



103
104
105
106
107
# File 'lib/source/redshift/accessors.rb', line 103

def get_property(attribute)
  `var el=this.__native__,attr=attribute.__value__,key=c$Element.__keyed_attributes__[attr],bool=c$Element.__boolean_attributes__[attr]`
  `var value=key||bool?el[key||bool]:el.getAttribute(attr,2)`
  return `bool ? !!value : (value==null) ? nil : $q(value)`
end

#get_style(attribute) ⇒ Object

call-seq:

elem.get_style(sym) -> object or nil

Returns the value of the CSS style rule sym applied to elem, or nil if no value is set.



117
118
119
120
# File 'lib/source/redshift/accessors.rb', line 117

def get_style(attribute)
  `var el=this.__native__,attr=attribute.__value__.replace(/[_-]\\D/g, function(match){return match.charAt(1).toUpperCase();}),result=el.style[attr]`
  `result===undefined?nil:$q(result)`
end

#has_class?(sym) ⇒ Boolean

call-seq:

elem.has_class?(sym) -> true or false

Returns true if elem has class sym, false otherwise.

<div id='div_a' class='container drop_target'></div>

elem = Document['#div_a']       #=> #<Element: DIV id="div_element" class="container drop_target">
elem.has_class?('container')    #=> true
elem.has_class?(:draggable)     #=> false

Returns:

  • (Boolean)


133
134
135
136
# File 'lib/source/redshift/accessors.rb', line 133

def has_class?(sym)
  `var str=' '+this.__native__.className+' ',match=' '+sym.__value__+' '`
  `str.indexOf(match) > -1`
end

#htmlObject

call-seq:

elem.html -> string

Returns a string representation of the HTML inside elem.



145
146
147
# File 'lib/source/redshift/accessors.rb', line 145

def html
  `$q(this.__native__.innerHTML)`
end

#html=(str) ⇒ Object

call-seq:

elem.html = str -> str

Sets the HTML inside elem to str.



156
157
158
159
# File 'lib/source/redshift/accessors.rb', line 156

def html=(str)
  `this.__native__.innerHTML=str.__value__`
  return str
end

#insert(element, where = :bottom) ⇒ Object

call-seq:

elem.insert(other, sym = :bottom) -> elem

Returns elem with other inserted at location sym.

Inserting into :bottom (default location):

<div id='a_element'>
  <div id='b_element'></div>
  <div id='c_element'></div>
</div>
<div id='d_element'></div>

elem  = Document['#a_element']
other = Document['#d_element']
elem.insert(other)

produces:

<div id='a_element'>
  <div id='b_element'></div>
  <div id='c_element'></div>
  <div id='d_element'></div>
</div>

Inserting into :top:

<div id='a_element'>
  <div id='b_element'></div>
  <div id='c_element'></div>
</div>
<div id='d_element'></div>

elem  = Document['#a_element']
other = Document['#d_element']
elem.insert(other, :top)

produces:

<div id='a_element'>
  <div id='d_element'></div>
  <div id='b_element'></div>
  <div id='c_element'></div>
</div>

Inserting :before:

<div id='a_element'>
  <div id='b_element'></div>
  <div id='c_element'></div>
</div>
<div id='d_element'></div>

elem  = Document['#a_element']
other = Document['#d_element']
elem.insert(other, :before)

produces:

<div id='d_element'></div>
<div id='a_element'>
  <div id='b_element'></div>
  <div id='c_element'></div>
</div>


204
205
206
207
# File 'lib/source/redshift/element.rb', line 204

def insert(element, where = :bottom)
  self.send("insert_#{where.to_s}", element)
  return self
end

#insert_after(element) ⇒ Object

:nodoc:



209
210
211
212
213
214
# File 'lib/source/redshift/element.rb', line 209

def insert_after(element) # :nodoc:
  `if (!element.parentNode) return`
  `next = #{self}.__native__.nextSibling`
  `(next) ? #{self}.__native__.parentNode.insertBefore(#{element}.__native__, next) : #{self}__native__.parentNode.appendChild(#{element}.__native__)`
  return true
end

#insert_before(element) ⇒ Object

:nodoc:



216
217
218
219
# File 'lib/source/redshift/element.rb', line 216

def insert_before(element) # :nodoc:
  `if (#{self}.__native__.parentNode) #{self}.__native__.parentNode.insertBefore(#{element}.__native__, #{self}.__native__)`
  return true
end

#insert_bottom(element) ⇒ Object Also known as: insert_inside

:nodoc:



221
222
223
224
# File 'lib/source/redshift/element.rb', line 221

def insert_bottom(element) # :nodoc:
  `#{self}.__native__.appendChild(#{element}.__native__)`
  return true
end

#insert_top(element) ⇒ Object

:nodoc:



227
228
229
230
231
# File 'lib/source/redshift/element.rb', line 227

def insert_top(element) # :nodoc:
  `first = #{self}.__native__.firstChild`
  `(first) ? #{self}.__native__.insertBefore(#{element}.__native__, first) : #{self}.__native__.appendChild(#{element}.__native__)`
  return true
end

#inspectObject

call-seq:

elem.inspect -> string

Returns a string representation of elem including its tag name, classes, and id.

<div style="width:300px" id="a_element" class="draggable container">

Document['#a_element'].inspect    #=> "#<Element: DIV id=\"a_element\" class=\"draggable container\">"


243
244
245
246
247
248
# File 'lib/source/redshift/element.rb', line 243

def inspect
  attributes = [`$q(this.__native__.tagName.toUpperCase())`]
  attributes << `$q('id="'+this.__native__.id+'"')` if `this.__native__.id!==''`
  attributes << `$q('class="'+this.__native__.className+'"')` if `this.__native__.className!==''`
  "#<Element: %s>" % attributes.join(' ')
end

#is_body?Boolean

call-seq:

elem.is_body? -> true or false

Returns true if the element is the body element, false otherwise.

Document['#my_div'].is_body?   #=> false
Document.body.is_body?         #=> true

Returns:

  • (Boolean)


258
259
260
# File 'lib/source/redshift/element.rb', line 258

def is_body?
  `(/^(?:body|html)$/i).test(#{self}.__native__.tagName)`
end

#last_child(match_selector = nil) ⇒ Object

call-seq:

elem.last_child -> element or nil

Returns the last child element of elem on the DOM tree, or nil if no such element is found.

<div id="container">
  <div id="a_element"></div>
  <div id="b_element"></div>
  <div id="c_element"></div>
  <div id="d_element"></div>
</div>

Document['#container'].last_child   #=> #<Element: DIV id="d_element">


277
278
279
# File 'lib/source/redshift/element.rb', line 277

def last_child(match_selector = nil)
  Document.walk(self, 'previousSibling', 'lastChild', match_selector, false)
end

#next_element(match_selector = nil) ⇒ Object

call-seq:

elem.next_element -> element or nil

Returns the sibling element immediately following elem on the DOM tree, or nil if no such element is found.

<div id='container'>
  <div id='a_element'></div>
  <div id='b_element'></div>
  <div id='c_element'></div>
  <div id='d_element'></div>
</div>

Document['#b_element'].next_element   #=> #<Element: DIV id="c_element">


296
297
298
# File 'lib/source/redshift/element.rb', line 296

def next_element(match_selector = nil)
  Document.walk(self, 'nextSibling', nil, match_selector, false)
end

#next_elements(match_selector = nil) ⇒ Object

call-seq:

elem.next_elements -> array

Returns the array of sibling elements that follow elem on the DOM tree.

<div id='container'>
  <div id='a_element'></div>
  <div id='b_element'></div>
  <div id='c_element'></div>
  <div id='d_element'></div>
</div>

elem = Document['#b_element']   #=> #<Element: DIV id="b_element">
elem.next_elements          #=> [#<Element: DIV id="c_element">, #<Element: DIV id="d_element">]


315
316
317
# File 'lib/source/redshift/element.rb', line 315

def next_elements(match_selector = nil)
  Document.walk(self, 'nextSibling', nil, match_selector, true)
end

#parent(match_selector = nil) ⇒ Object

call-seq:

elem.parent -> element or nil

Returns the parent element of elem on the DOM tree, or nil if no such element is found.

<div id="container">
  <div id="a_element"></div>
  <div id="b_element"></div>
  <div id="c_element"></div>
  <div id="d_element"></div>
</div>

Document['#c_element'].parent   #=> #<Element: DIV id="container">
Document.body.parent            #=> #<Element: HTML>
Document.body.parent.parent     #=> nil


336
337
338
# File 'lib/source/redshift/element.rb', line 336

def parent(match_selector = nil)
  Document.walk(self, 'parentNode', nil, match_selector, false)
end

#parents(match_selector = nil) ⇒ Object

call-seq:

elem.parents -> [element, ...]

Returns the array of elem’s ancestors on the DOM tree.

<div id='container'>
  <div id='a_element'></div>
  <div id='b_element'>
    <div id='b_inner_element'></div>
  </div>
  <div id='c_element'></div>
  <div id='d_element'></div>
</div>

Document['#b_inner_element'].parents    #=> [#<Element: DIV id="b_element">, #<Element: DIV id="container">, <Element: BODY>, <Element: HTML>]
Document.html.parents                   #=> []


357
358
359
# File 'lib/source/redshift/element.rb', line 357

def parents(match_selector = nil)
  Document.walk(self, 'parentNode', nil, match_selector, true)
end

#previous_element(match_selector = nil) ⇒ Object

call-seq:

elem.previous_element -> element or nil

Returns the sibling element immediately preceding elem on the DOM tree, or nil if no such element is found.

<div id='container'>
  <div id='a_element'></div>
  <div id='b_element'></div>
  <div id='c_element'></div>
  <div id='d_element'></div>
</div>

Document['#b_element'].previous_element   #=> #<Element: DIV id="a_element">


376
377
378
# File 'lib/source/redshift/element.rb', line 376

def previous_element(match_selector = nil)
  Document.walk(self, 'previousSibling', nil, match_selector, false)
end

#previous_elements(match_selector = nil) ⇒ Object

call-seq:

elem.previous_elements -> array

Returns the array of sibling elements that precede elem on the DOM tree.

<div id='container'>
  <div id='a_element'></div>
  <div id='b_element'></div>
  <div id='c_element'></div>
  <div id='d_element'></div>
</div>

elem = Document['#c_element']   #=> #<Element: DIV id="c_element">
elem.previous_elements          #=> [#<Element: DIV id="a_element">, #<Element: DIV id="b_element">]


395
396
397
# File 'lib/source/redshift/element.rb', line 395

def previous_elements(match_selector = nil)
  Document.walk(self, 'previousSibling', nil, match_selector, true)
end

#propertiesObject

call-seq:

elem.properties -> object

Returns an Element::Properties accessor object, which represents the HTML properties assigned to elem, and allows for operations such as elem.properties[:title] = 'figure_1' and elem.properties.set? :name.



171
172
173
# File 'lib/source/redshift/accessors.rb', line 171

def properties
  @properties ||= Element::Properties.new(self)
end

#remove!Object

call-seq:

elem.remove! -> elem

Removes elem and all of its child elements from the page, then returns elem.



405
406
407
408
# File 'lib/source/redshift/element.rb', line 405

def remove!
  Element.remove(self)
  return self
end

#remove_class(sym) ⇒ Object

call-seq:

elem.remove_class(sym) -> elem

Removes sym from elem’s HTML class property if it was included, then returns elem.



183
184
185
186
187
# File 'lib/source/redshift/accessors.rb', line 183

def remove_class(sym)
  `var el=this.__native__,klass=sym.__value__`
  `el.className=el.className.replace(new(RegExp)('(^|\\\\s)'+klass+'(?:\\\\s|$)'),'$1')`
  return self
end

#remove_classes(*args) ⇒ Object

call-seq:

elem.remove_classes(sym, ...) -> elem

Calls elem.remove_class(sym) once for each argument.



196
197
198
199
# File 'lib/source/redshift/accessors.rb', line 196

def remove_classes(*args)
  args.each {|x| self.remove_class(x) }
  return self
end

#remove_properties(*args) ⇒ Object

call-seq:

elem.remove_properties(sym, ...) -> elem

Calls elem.remove_property(sym) once for each argument.



221
222
223
224
# File 'lib/source/redshift/accessors.rb', line 221

def remove_properties(*args)
  args.each {|x| self.remove_property(x) }
  return self
end

#remove_property(attribute) ⇒ Object

call-seq:

elem.remove_property(sym) -> elem

Unsets elem’s HTML property sym if it was set, then returns elem.



208
209
210
211
212
# File 'lib/source/redshift/accessors.rb', line 208

def remove_property(attribute)
  `var el=this.__native__,attr=attribute.__value__,bool=c$Element.__boolean_attributes__[attr],key=c$Element.__boolean_attributes__[attr]||bool`
  `key ? el[key]=bool?false:'' : el.removeAttribute(attr)`
  return self
end

#remove_style(attribute) ⇒ Object

call-seq:

elem.remove_style(sym) -> elem

Unsets elem’s CSS style sym if it was set, then returns elem.



233
234
235
236
237
# File 'lib/source/redshift/accessors.rb', line 233

def remove_style(attribute)
  `var attr=attribute.__value__.replace(/[_-]\\D/g, function(match){return match.charAt(1).toUpperCase();})`
  `this.__native__.style[attr]=null`
  return self
end

#remove_styles(*args) ⇒ Object

call-seq:

elem.remove_styles(sym, ...) -> elem

Calls elem.remove_style(sym) once for each argument.



246
247
248
249
# File 'lib/source/redshift/accessors.rb', line 246

def remove_styles(*args)
  args.each {|x| self.remove_style(x) }
  return self
end

#set_properties(hash) ⇒ Object

call-seq:

elem.set_properties({key => value, ...}) -> elem

Calls elem.set_property(key,value) once for each key-value pair.



271
272
273
274
# File 'lib/source/redshift/accessors.rb', line 271

def set_properties(hash)
  hash.each {|k,v| self.set_property(k,v) }
  return self
end

#set_property(attribute, value) ⇒ Object

call-seq:

elem.set_property(sym, value) -> elem

Sets elem’s HTML property sym to value, then returns elem.



258
259
260
261
262
# File 'lib/source/redshift/accessors.rb', line 258

def set_property(attribute, value)
  `var el=this.__native__,attr=attribute.__value__,bool=c$Element.__boolean_attributes__[attr],key=c$Element.__boolean_attributes__[attr]||bool`
  `key ? el[key]=bool?$T(value):value : el.setAttribute(attr,''+value)`
  return self
end

#set_style(attribute, value) ⇒ Object

call-seq:

elem.set_style(sym, value) -> elem

Sets elem’s CSS style sym to value, then returns elem.



283
284
285
286
287
288
289
290
# File 'lib/source/redshift/accessors.rb', line 283

def set_style(attribute, value)
  `var attr=attribute.__value__.replace(/[_-]\\D/g, function(match){return match.charAt(1).toUpperCase();}),val=value.__value__||value`
  `if(attr==='float'){val=#{trident?}?'styleFloat':'cssFloat'}`
  `if(attr==='opacity'){m$raise("nobody wrote the opacity setter yet!");}`
  `if(val===String(Number(val))){val=Math.round(val)}`
  `this.__native__.style[attr]=val`
  return self
end

#set_styles(hash) ⇒ Object

call-seq:

elem.set_styles({key => value, ...}) -> elem

Calls elem.set_style(key,value) once for each key-value pair.



299
300
301
302
# File 'lib/source/redshift/accessors.rb', line 299

def set_styles(hash)
  hash.each {|k,v| self.set_style(k,v) }
  return self
end

#styleObject

call-seq:

elem.style -> string

Returns the value of elem’s HTML style property.



311
312
313
# File 'lib/source/redshift/accessors.rb', line 311

def style
  `$q(this.__native__.style.cssText)`
end

#style=(str) ⇒ Object

call-seq:

elem.style = str -> str

Sets the value of elem’s HTML style property to str.



322
323
324
325
# File 'lib/source/redshift/accessors.rb', line 322

def style=(str)
  `this.__native__.style.cssText=str.__value__`
  return str
end

#stylesObject

call-seq:

elem.styles -> object

Returns an Element::Styles accessor object, which represents the CSS styles applied to elem, and allows for operations such as elem.styles[:color] = '#C80404' and elem.styles.set? :font_weight.



337
338
339
# File 'lib/source/redshift/accessors.rb', line 337

def styles
  @styles ||= Element::Styles.new(self)
end

#textObject

call-seq:

elem.text -> string

Returns the text inside elem as a string.



348
349
350
# File 'lib/source/redshift/accessors.rb', line 348

def text
  `$q(#{trident?} ? this.__native__.innerText : this.__native__.textContent)`
end

#text=(str) ⇒ Object

call-seq:

elem.text = str -> str

Sets the text inside elem to the value str.



359
360
361
362
# File 'lib/source/redshift/accessors.rb', line 359

def text=(str)
  trident? ? `this.__native__.innerText=str.__value__` : `this.__native__.textContent=str.__value__`
  return str
end

#to_sObject

call-seq:

elem.to_s -> string

FIX: Incomplete



415
416
417
# File 'lib/source/redshift/element.rb', line 415

def to_s
  
end

#toggle_class(sym) ⇒ Object

call-seq:

elem.toggle_class(sym) -> elem

Returns elem with the HTML class sym added to its HTML classes if they did not include sym, or with sym removed from its HTML classes if they did include sym.



373
374
375
376
# File 'lib/source/redshift/accessors.rb', line 373

def toggle_class(sym)
  self.has_class?(sym) ? self.remove_class(sym) : self.add_class(sym);
  return self
end