911e285333
Bug: https://github.com/dart-lang/sdk/issues/29325 Change-Id: Id66b414e996e37b3ddd7469bbbb0deb4601a2171 Reviewed-on: https://dart-review.googlesource.com/63221 Reviewed-by: Terry Lucas <terry@google.com> Commit-Queue: Samuel Rawlins <srawlins@google.com>
99 lines
2.9 KiB
Plaintext
99 lines
2.9 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)$(NATIVESPEC)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS {
|
|
factory $CLASSNAME() => document.createDocumentFragment();
|
|
|
|
factory $CLASSNAME.html(String html,
|
|
{NodeValidator validator, NodeTreeSanitizer treeSanitizer}) {
|
|
|
|
return document.body.createFragment(html,
|
|
validator: validator, treeSanitizer: treeSanitizer);
|
|
}
|
|
|
|
factory $CLASSNAME.svg(String svgContent,
|
|
{NodeValidator validator, NodeTreeSanitizer treeSanitizer}) {
|
|
|
|
return new svg.SvgSvgElement().createFragment(svgContent,
|
|
validator: validator, treeSanitizer: treeSanitizer);
|
|
}
|
|
|
|
HtmlCollection get _children => throw new UnimplementedError(
|
|
'Use _docChildren instead');
|
|
|
|
// Native field is used only by Dart code so does not lead to instantiation
|
|
// of native classes
|
|
@Creates('Null')
|
|
List<Element> _docChildren;
|
|
|
|
List<Element> get children {
|
|
if (_docChildren == null) {
|
|
_docChildren = new FilteredElementList(this);
|
|
}
|
|
return _docChildren;
|
|
}
|
|
|
|
set children(List<Element> value) {
|
|
// Copy list first since we don't want liveness during iteration.
|
|
var copy = value.toList();
|
|
var children = this.children;
|
|
children.clear();
|
|
children.addAll(copy);
|
|
}
|
|
|
|
/**
|
|
* Finds all descendant elements of this document fragment that match the
|
|
* specified group of selectors.
|
|
*
|
|
* [selectors] should be a string using CSS selector syntax.
|
|
*
|
|
* var items = document.querySelectorAll('.itemClassName');
|
|
*
|
|
* For details about CSS selector syntax, see the
|
|
* [CSS selector specification](http://www.w3.org/TR/css3-selectors/).
|
|
*/
|
|
ElementList<T> querySelectorAll<T extends Element>(String selectors) =>
|
|
new _FrozenElementList<T>._wrap(_querySelectorAll(selectors));
|
|
|
|
String get innerHtml {
|
|
final e = new DivElement();
|
|
e.append(this.clone(true));
|
|
return e.innerHtml;
|
|
}
|
|
|
|
set innerHtml(String value) {
|
|
this.setInnerHtml(value);
|
|
}
|
|
|
|
void setInnerHtml(String html,
|
|
{NodeValidator validator, NodeTreeSanitizer treeSanitizer}) {
|
|
|
|
this.nodes.clear();
|
|
append(document.body.createFragment(
|
|
html, validator: validator, treeSanitizer: treeSanitizer));
|
|
}
|
|
|
|
/**
|
|
* Adds the specified text as a text node after the last child of this
|
|
* document fragment.
|
|
*/
|
|
void appendText(String text) {
|
|
this.append(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,
|
|
{NodeValidator validator, NodeTreeSanitizer treeSanitizer}) {
|
|
this.append(new DocumentFragment.html(text, validator: validator,
|
|
treeSanitizer: treeSanitizer));
|
|
}
|
|
$!MEMBERS
|
|
}
|