internalCloneWithOwnerDocument method

  1. @visibleForTesting
  2. @override
Element internalCloneWithOwnerDocument(
  1. Document ownerDocument,
  2. bool deep
)
override

Implementation

@visibleForTesting
@override
Element internalCloneWithOwnerDocument(Document ownerDocument, bool deep) {
  // Create a new instance of the same class
  final clone = _newInstance(ownerDocument);

  // Clone attributes
  clone._firstAttribute = _firstAttribute?.cloneChain();

  // Clone style
  clone._style = _style?._clone();

  // Clone children
  if (deep != false) {
    Node._cloneChildrenFrom(ownerDocument, newParent: clone, oldParent: this);
  }

  return clone;
}