| Index: client/html/src/XMLDocumentWrappingImplementation.dart
|
| diff --git a/client/html/src/XMLDocumentWrappingImplementation.dart b/client/html/src/XMLDocumentWrappingImplementation.dart
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..55b1bd5ff2b96a4273633951703aee7bc9dfcb4c
|
| --- /dev/null
|
| +++ b/client/html/src/XMLDocumentWrappingImplementation.dart
|
| @@ -0,0 +1,149 @@
|
| +// 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.
|
| +
|
| +class XMLDocumentWrappingImplementation extends DocumentWrappingImplementation
|
| + implements XMLDocument {
|
| + // This really just wants to extend both DocumentWrappingImplementation and
|
| + // XMLElementWrappingImplementation, but since that's not possible we delegate
|
| + // to the latter.
|
| + XMLElement documentEl;
|
| +
|
| + XMLDocumentWrappingImplementation._wrap(documentPtr, ptr) :
|
| + super._wrap(documentPtr, ptr) {
|
| + // We want to wrap the pointer in an XMLElement to use its implementation of
|
| + // various Element methods, but DOMWrapperBase complains if
|
| + // dartObjectLocalStorage is already set.
|
| + ptr.dartObjectLocalStorage = null;
|
| + this.documentEl = new XMLElementWrappingImplementation._wrap(ptr);
|
| + ptr.dartObjectLocalStorage = this;
|
| + }
|
| +
|
| + factory XMLDocumentWrappingImplementation.xml(String xml) {
|
| + final parser = new dom.DOMParser();
|
| + final xmlDoc = LevelDom.wrapDocument(
|
| + parser.parseFromString(xml, 'text/xml'));
|
| + // When XML parsing fails, the browser creates a document containing a
|
| + // PARSERERROR element. We want to throw an exception when parsing fails,
|
| + // but we don't want false positives if the user intends to create a
|
| + // PARSERERROR element for some reason, so we check for that in the input.
|
| + //
|
| + // TODO(nweiz): This is pretty hacky, it would be nice to this some other
|
| + // way if we can find one.
|
| + if (!xml.toLowerCase().contains('<parsererror') &&
|
| + xmlDoc.query('parsererror') != null) {
|
| + throw new IllegalArgumentException('Error parsing XML: "$xml"');
|
| + }
|
| + return xmlDoc;
|
| + }
|
| +
|
| + Node get parent() => null;
|
| +
|
| + Node _insertAdjacentNode(String where, Node node) {
|
| + switch (where.toLowerCase()) {
|
| + case "beforebegin":
|
| + return null;
|
| + case "afterend":
|
| + return null;
|
| + case "afterbegin":
|
| + this.insertBefore(node, nodes.first);
|
| + return node;
|
| + case "beforeend":
|
| + this.nodes.add(node);
|
| + return node;
|
| + default:
|
| + throw new IllegalArgumentException("Invalid position ${where}");
|
| + }
|
| + }
|
| +
|
| + XMLElement insertAdjacentElement([String where = null,
|
| + XMLElement element = null]) => this._insertAdjacentNode(where, element);
|
| +
|
| + void insertAdjacentText([String where = null, String text = null]) {
|
| + this._insertAdjacentNode(where, new Text(text));
|
| + }
|
| +
|
| + void insertAdjacentHTML(
|
| + [String position_OR_where = null, String text = null]) {
|
| + this._insertAdjacentNode(
|
| + position_OR_where, new DocumentFragment.xml(text));
|
| + }
|
| +
|
| + XMLElement get activeElement() => null;
|
| +
|
| + void set body(Element value) {
|
| + throw new UnsupportedOperationException("XML documents don't have a body.");
|
| + }
|
| +
|
| + String get cookie() {
|
| + throw new UnsupportedOperationException(
|
| + "XML documents don't support cookies.");
|
| + }
|
| +
|
| + void set cookie(String value) {
|
| + throw new UnsupportedOperationException(
|
| + "XML documents don't support cookies.");
|
| + }
|
| +
|
| + String get manifest() => "";
|
| +
|
| + void set manifest(String value) {
|
| + throw new UnsupportedOperationException(
|
| + "Manifest can't be set for XML documents.");
|
| + }
|
| +
|
| + Set<String> get classes() => documentEl.classes;
|
| +
|
| + ElementList get elements() => documentEl.elements;
|
| +
|
| + // TODO: The type of value should be Collection<Element>. See http://b/5392897
|
| + void set elements(value) { documentEl.elements = value; }
|
| +
|
| + String get outerHTML() => documentEl.outerHTML;
|
| +
|
| + String get innerHTML() => documentEl.innerHTML;
|
| +
|
| + void set innerHTML(String xml) { documentEl.innerHTML = xml; }
|
| +
|
| + String get contentEditable() => documentEl.contentEditable;
|
| +
|
| + void set contentEditable(String value) { documentEl.contentEditable = value; }
|
| +
|
| + bool get isContentEditable() => documentEl.isContentEditable;
|
| +
|
| + bool get draggable() => documentEl.draggable;
|
| +
|
| + void set draggable(bool value) { documentEl.draggable = value; }
|
| +
|
| + bool get spellcheck() => documentEl.spellcheck;
|
| +
|
| + void set spellcheck(bool value) { documentEl.spellcheck = value; }
|
| +
|
| + bool get hidden() => documentEl.hidden;
|
| +
|
| + void set hidden(bool value) { documentEl.hidden = value; }
|
| +
|
| + int get tabIndex() => documentEl.tabIndex;
|
| +
|
| + void set tabIndex(int value) { documentEl.tabIndex = value; }
|
| +
|
| + String get id() => documentEl.id;
|
| +
|
| + void set id(String value) { documentEl.id = value; }
|
| +
|
| + String get title() => documentEl.title;
|
| +
|
| + void set title(String value) { documentEl.title = value; }
|
| +
|
| + String get webkitdropzone() => documentEl.webkitdropzone;
|
| +
|
| + void set webkitdropzone(String value) { documentEl.webkitdropzone = value; }
|
| +
|
| + String get lang() => documentEl.lang;
|
| +
|
| + void set lang(String value) { documentEl.lang = value; }
|
| +
|
| + String get dir() => documentEl.dir;
|
| +
|
| + void set dir(String value) { documentEl.dir = value; }
|
| +}
|
|
|