f05f2c77cc
BUG= Review URL: https://codereview.chromium.org//12219002 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@18111 260f80e4-7a28-3924-810f-c04153c831b5
89 lines
2.4 KiB
Plaintext
89 lines
2.4 KiB
Plaintext
// Copyright (c) 2011, 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.
|
|
|
|
part of $LIBRARYNAME;
|
|
|
|
$(ANNOTATIONS)class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
|
|
factory $CLASSNAME() => _$(CLASSNAME)FactoryProvider.createDocumentFragment();
|
|
|
|
factory $CLASSNAME.html(String html) =>
|
|
_$(CLASSNAME)FactoryProvider.createDocumentFragment_html(html);
|
|
|
|
factory $CLASSNAME.svg(String svgContent) =>
|
|
_$(CLASSNAME)FactoryProvider.createDocumentFragment_svg(svgContent);
|
|
|
|
$if DART2JS
|
|
// Native field is used only by Dart code so does not lead to instantiation
|
|
// of native classes
|
|
@Creates('Null')
|
|
$endif
|
|
List<Element> _children;
|
|
|
|
List<Element> get children {
|
|
if (_children == null) {
|
|
_children = new FilteredElementList(this);
|
|
}
|
|
return _children;
|
|
}
|
|
|
|
void set children(List<Element> value) {
|
|
// Copy list first since we don't want liveness during iteration.
|
|
List copy = new List.from(value);
|
|
var children = this.children;
|
|
children.clear();
|
|
children.addAll(copy);
|
|
}
|
|
|
|
Element query(String selectors) => $dom_querySelector(selectors);
|
|
|
|
List<Element> queryAll(String selectors) =>
|
|
new _FrozenElementList._wrap($dom_querySelectorAll(selectors));
|
|
|
|
String get innerHtml {
|
|
final e = new Element.tag("div");
|
|
e.nodes.add(this.clone(true));
|
|
return e.innerHtml;
|
|
}
|
|
|
|
// TODO(nweiz): Do we want to support some variant of innerHtml for XML and/or
|
|
// SVG strings?
|
|
void set innerHtml(String value) {
|
|
this.nodes.clear();
|
|
|
|
final e = new Element.tag("div");
|
|
e.innerHtml = value;
|
|
|
|
// Copy list first since we don't want liveness during iteration.
|
|
List nodes = new List.from(e.nodes);
|
|
this.nodes.addAll(nodes);
|
|
}
|
|
|
|
/**
|
|
* Adds the specified element after the last child of this
|
|
* document fragment.
|
|
*/
|
|
void append(Element element) {
|
|
this.children.add(element);
|
|
}
|
|
|
|
/**
|
|
* Adds the specified text as a text node after the last child of this
|
|
* document fragment.
|
|
*/
|
|
void appendText(String text) {
|
|
this.nodes.add(new Text(text));
|
|
}
|
|
|
|
|
|
/**
|
|
* Parses the specified text as HTML and adds the resulting node after the
|
|
* last child of this document fragment.
|
|
*/
|
|
void appendHtml(String text) {
|
|
this.nodes.add(new DocumentFragment.html(text));
|
|
}
|
|
|
|
$!MEMBERS
|
|
}
|