blob: c9b9b11a4825e7311717e6c7d1fdb560510c686b [file] [log] [blame]
// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// @dart = 2.9
/// @assertion Node clone(bool deep)
/// Returns a copy of this node.
/// MDN: The duplicate node returned by cloneNode() is not part of the document
/// until it is added to another node that is part of the document using
/// Node.appendChild() or a similar method. It also has no parent until it is
/// appended to another node.
/// @description Checks that parent is not set after clone.
import "dart:html";
import "../../../Utils/expect.dart";
main() {
var x = new Element.html('<div><pre></pre></div>');
var y = x.clone(false);
Expect.isNull(y.parent, 'parent of shallow copy');
y = x.clone(true);
Expect.isNull(y.parent, 'parent of deep copy');
}