118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
|
# File 'lib/taka/dom/node.rb', line 118
def insertBefore new_child, ref_child
unless can_append?(new_child)
raise DOMException.new(DOMException::HIERARCHY_REQUEST_ERR)
end
if read_only?
raise DOMException.new(DOMException::NO_MODIFICATION_ALLOWED_ERR)
end
if ref_child && !children.include?(ref_child)
raise DOMException.new(DOMException::NOT_FOUND_ERR)
end
if ancestors.include?(new_child)
raise DOMException.new(DOMException::HIERARCHY_REQUEST_ERR)
end
if new_child.document != document
raise DOMException.new(DOMException::WRONG_DOCUMENT_ERR)
end
unless ref_child
new_child.parent = self
else
return ref_child.add_previous_sibling(new_child)
end
new_child
end
|