MCPcopy
hub / github.com/csev/py4e / insertBefore

Method insertBefore

code3/bs4/builder/_html5lib.py:233–243  ·  view source on GitHub ↗
(self, node, refNode)

Source from the content-addressed store, hash-verified

231 self.appendChild(data)
232
233 def insertBefore(self, node, refNode):
234 index = self.element.index(refNode.element)
235 if (node.element.__class__ == NavigableString and self.element.contents
236 and self.element.contents[index-1].__class__ == NavigableString):
237 # (See comments in appendChild)
238 old_node = self.element.contents[index-1]
239 new_str = self.soup.new_string(old_node + node.element)
240 old_node.replace_with(new_str)
241 else:
242 self.element.insert(index, node.element)
243 node.parent = self
244
245 def removeChild(self, node):
246 node.element.extract()

Callers 15

insertTextMethod · 0.95
patchDisplayFunction · 0.45
updateGutterFunction · 0.45
measureLineFunction · 0.45
codemirrorepl.jsFile · 0.45
patchDisplayFunction · 0.45
updateLineBackgroundFunction · 0.45
updateLineGutterFunction · 0.45
insertLineWidgetsForFunction · 0.45
codemirror.jsFile · 0.45
patchDisplayFunction · 0.45
buildLineElementFunction · 0.45

Calls 4

indexMethod · 0.45
new_stringMethod · 0.45
replace_withMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected