Lines Matching refs:new_child
297 def insert(self, position, new_child): argument
298 if new_child is None:
300 if new_child is self:
302 if (isinstance(new_child, str)
303 and not isinstance(new_child, NavigableString)):
304 new_child = NavigableString(new_child)
307 if hasattr(new_child, 'parent') and new_child.parent is not None:
310 if new_child.parent is self:
311 current_index = self.index(new_child)
318 new_child.extract()
320 new_child.parent = self
323 new_child.previous_sibling = None
324 new_child.previous_element = self
327 new_child.previous_sibling = previous_child
328 new_child.previous_sibling.next_sibling = new_child
329 new_child.previous_element = previous_child._last_descendant(False)
330 if new_child.previous_element is not None:
331 new_child.previous_element.next_element = new_child
333 new_childs_last_element = new_child._last_descendant(False)
336 new_child.next_sibling = None
354 new_child.next_sibling = next_child
355 if new_child.next_sibling is not None:
356 new_child.next_sibling.previous_sibling = new_child
361 self.contents.insert(position, new_child)