Module: Taka::DOM::Element

Defined in:
lib/taka/dom/element.rb

Instance Method Summary collapse

Instance Method Details

#getAttribute(name) ⇒ Object



8
9
10
# File 'lib/taka/dom/element.rb', line 8

def getAttribute(name)
  self[name]
end

#getAttributeNode(name) ⇒ Object



33
34
35
# File 'lib/taka/dom/element.rb', line 33

def getAttributeNode name
  self.attribute(name)
end

#getAttributeNodeNS(namespaceURI, localName) ⇒ Object

Raises:

  • (NotImplementedError)


68
69
70
# File 'lib/taka/dom/element.rb', line 68

def getAttributeNodeNS(namespaceURI, localName)
  raise(NotImplementedError.new)
end

#getAttributeNS(namespaceURI, localName) ⇒ Object

Raises:

  • (NotImplementedError)


59
60
61
# File 'lib/taka/dom/element.rb', line 59

def getAttributeNS(namespaceURI, localName)
  raise(NotImplementedError.new)
end

#getElementsByTagName(name) ⇒ Object



53
54
55
56
57
# File 'lib/taka/dom/element.rb', line 53

def getElementsByTagName(name)
  DOM::NodeList.new do
    css(name)
  end
end

#getElementsByTagNameNS(namespaceURI, localName) ⇒ Object

Raises:

  • (NotImplementedError)


74
75
76
# File 'lib/taka/dom/element.rb', line 74

def getElementsByTagNameNS(namespaceURI, localName)
  raise(NotImplementedError.new)
end

#hasAttribute(name) ⇒ Object

Raises:

  • (NotImplementedError)


77
78
79
# File 'lib/taka/dom/element.rb', line 77

def hasAttribute(name)
  raise(NotImplementedError.new)
end

#hasAttributeNS(namespaceURI, localName) ⇒ Object

Raises:

  • (NotImplementedError)


80
81
82
# File 'lib/taka/dom/element.rb', line 80

def hasAttributeNS(namespaceURI, localName)
  raise(NotImplementedError.new)
end

#removeAttribute(name) ⇒ Object



26
27
28
29
30
31
# File 'lib/taka/dom/element.rb', line 26

def removeAttribute(name)
  if read_only?
    raise DOMException.new(DOMException::NO_MODIFICATION_ALLOWED_ERR)
  end
  self.remove_attribute(name)
end

#removeAttributeNode(old_attribute) ⇒ Object



49
50
51
# File 'lib/taka/dom/element.rb', line 49

def removeAttributeNode old_attribute
  remove_attribute old_attribute.name
end

#removeAttributeNS(namespaceURI, localName) ⇒ Object

Raises:

  • (NotImplementedError)


65
66
67
# File 'lib/taka/dom/element.rb', line 65

def removeAttributeNS(namespaceURI, localName)
  raise(NotImplementedError.new)
end

#setAttribute(name, value) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/taka/dom/element.rb', line 12

def setAttribute(name, value)
  if read_only? || [
    Node::TEXT_NODE,
    Node::ENTITY_DECL
  ].include?(nodeType)
    raise DOMException.new(DOMException::NO_MODIFICATION_ALLOWED_ERR)
  end

  if name.length == 0 || name !~ /^\w+$/
    raise DOMException.new(DOMException::INVALID_CHARACTER_ERR)
  end
  self[name] = value
end

#setAttributeNode(new_attribute) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
# File 'lib/taka/dom/element.rb', line 37

def setAttributeNode new_attribute
  if read_only? || [
    Node::TEXT_NODE,
    Node::ENTITY_DECL
  ].include?(nodeType)
    raise DOMException.new(DOMException::NO_MODIFICATION_ALLOWED_ERR)
  end
  old_attribute = self.getAttributeNode(new_attribute.name)
  self[new_attribute.name] = new_attribute.value
  old_attribute
end

#setAttributeNodeNS(newAttr) ⇒ Object

Raises:

  • (NotImplementedError)


71
72
73
# File 'lib/taka/dom/element.rb', line 71

def setAttributeNodeNS(newAttr)
  raise(NotImplementedError.new)
end

#setAttributeNS(namespaceURI, qualifiedName, value) ⇒ Object

Raises:

  • (NotImplementedError)


62
63
64
# File 'lib/taka/dom/element.rb', line 62

def setAttributeNS(namespaceURI, qualifiedName, value)
  raise(NotImplementedError.new)
end

#tagNameObject



4
5
6
# File 'lib/taka/dom/element.rb', line 4

def tagName
  self.name
end