Class: Browser::DOM::Text

Inherits:
CharacterData show all
Defined in:
opal/browser/dom/text.rb

Overview

Encapsulates a text node.

Direct Known Subclasses

CDATA

Constant Summary

Constants inherited from Node

Node::ATTRIBUTE_NODE, Node::CDATA_SECTION_NODE, Node::COMMENT_NODE, Node::DOCUMENT_FRAGMENT_NODE, Node::DOCUMENT_NODE, Node::DOCUMENT_TYPE_NODE, Node::ELEMENT_NODE, Node::ENTITY_NODE, Node::ENTITY_REFERENCE_NOCE, Node::NOTATION_NODE, Node::PROCESSING_INSTRUCTION_NODE, Node::TEXT_NODE

Instance Attribute Summary collapse

Attributes inherited from CharacterData

#data, #length

Attributes inherited from Node

#child, #children, #document, #element_children, #first_element_child, #last_element_child, #name, #namespace, #next, #next_element, #node_type, #outer_html, #parent, #previous, #previous_element, #value

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from CharacterData

#append, #delete, #insert, #replace, #substring

Methods inherited from Node

#<<, #==, #>>, #add_child, #add_next_sibling, #add_previous_sibling, #ancestors, #append_to, #attached?, #blank?, #cdata?, #clear, #comment?, #content, #content=, #custom?, #document?, #elem?, #fragment?, #initialize, #initialize_copy, new, #parse, #path, #prepend_to, #remove, #remove_child, #replace, #text?, #traverse

Methods included from NativeCachedWrapper

#restricted?, #set_native_reference

Constructor Details

This class inherits a constructor from Browser::DOM::Node

Instance Attribute Details

#wholeString (readonly)

Returns the whole text.



17
18
19
# File 'opal/browser/dom/text.rb', line 17

def whole
  `#@native.wholeText`
end

Class Method Details

.create(content) ⇒ Text

Create a new text node for the document.

Parameters:

  • content (String)

    the text content

Returns:



9
10
11
# File 'opal/browser/dom/text.rb', line 9

def self.create(content)
  $document.create_text(content)
end

Instance Method Details

#inspectObject



32
33
34
# File 'opal/browser/dom/text.rb', line 32

def inspect
  "#<DOM::Text: #{data}>"
end

#split(offset) ⇒ Text

Split the text node at a given offset.

Parameters:

  • offset (Integer)

    the offset where to split the text node

Returns:

  • (Text)

    the newly created text node

See Also:



28
29
30
# File 'opal/browser/dom/text.rb', line 28

def split(offset)
  DOM(`#@native.splitText(offset)`)
end