blob: 0355ba98d2fd53131fec54b8dcdb204c139dac17 [file] [log] [blame]
// Copyright (c) 2012, 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 html;
class _CssStyleDeclarationFactoryProvider {
static CssStyleDeclaration createCssStyleDeclaration_css(String css) {
final style = new Element.tag('div').style;
style.cssText = css;
return style;
}
static CssStyleDeclaration createCssStyleDeclaration() {
return new CssStyleDeclaration.css('');
}
}
class _DocumentFragmentFactoryProvider {
@DomName('Document.createDocumentFragment')
static DocumentFragment createDocumentFragment() =>
document.createDocumentFragment();
static DocumentFragment createDocumentFragment_html(String html) {
final fragment = new DocumentFragment();
fragment.innerHtml = html;
return fragment;
}
// TODO(nweiz): enable this when XML is ported.
// factory DocumentFragment.xml(String xml) {
// final fragment = new DocumentFragment();
// final e = new XMLElement.tag("xml");
// e.innerHtml = xml;
//
// // Copy list first since we don't want liveness during iteration.
// final List nodes = new List.from(e.nodes);
// fragment.nodes.addAll(nodes);
// return fragment;
// }
static DocumentFragment createDocumentFragment_svg(String svgContent) {
final fragment = new DocumentFragment();
final e = new svg.SvgSvgElement();
e.innerHtml = svgContent;
// Copy list first since we don't want liveness during iteration.
final List nodes = new List.from(e.nodes);
fragment.nodes.addAll(nodes);
return fragment;
}
}