| Index: sdk/lib/html/dartium/html_dartium.dart
|
| diff --git a/sdk/lib/html/dartium/html_dartium.dart b/sdk/lib/html/dartium/html_dartium.dart
|
| index e35b74a77d30f9ee693ec4b66d355a2f51a62e65..87e85c4828fe51f2b54c8e073ab0adb20164cd4c 100644
|
| --- a/sdk/lib/html/dartium/html_dartium.dart
|
| +++ b/sdk/lib/html/dartium/html_dartium.dart
|
| @@ -9988,140 +9988,6 @@ abstract class Element extends Node implements ParentNode, ChildNode {
|
| return false;
|
| }
|
|
|
| - Element _templateInstanceRef;
|
| -
|
| - // Note: only used if `this is! TemplateElement`
|
| - DocumentFragment _templateContent;
|
| -
|
| - bool _templateIsDecorated;
|
| -
|
| -
|
| -
|
| - /**
|
| - * Gets the template this node refers to.
|
| - * This is only supported if [isTemplate] is true.
|
| - */
|
| - @Experimental()
|
| - Element get ref {
|
| - _ensureTemplate();
|
| -
|
| - Element result = null;
|
| - var refId = attributes['ref'];
|
| - if (refId != null) {
|
| - var treeScope = this;
|
| - while (treeScope.parentNode != null) {
|
| - treeScope = treeScope.parentNode;
|
| - }
|
| -
|
| - // Note: JS code tests that getElementById is present. We can't do that
|
| - // easily, so instead check for the types known to implement it.
|
| - if (treeScope is Document ||
|
| - treeScope is ShadowRoot ||
|
| - treeScope is svg.SvgSvgElement) {
|
| -
|
| - result = treeScope.getElementById(refId);
|
| - }
|
| - }
|
| -
|
| - if (result == null) {
|
| - result = _templateInstanceRef;
|
| - if (result == null) return this;
|
| - }
|
| -
|
| - var nextRef = result.ref;
|
| - return nextRef != null ? nextRef : result;
|
| - }
|
| -
|
| - /**
|
| - * Gets the content of this template.
|
| - * This is only supported if [isTemplate] is true.
|
| - */
|
| - @Experimental()
|
| - DocumentFragment get content {
|
| - _ensureTemplate();
|
| - return _templateContent;
|
| - }
|
| -
|
| - /**
|
| - * Creates an instance of the template, using the provided model and optional
|
| - * binding delegate.
|
| - *
|
| - * This is only supported if [isTemplate] is true.
|
| - */
|
| - @Experimental()
|
| - DocumentFragment createInstance(model, [BindingDelegate delegate]) {
|
| - _ensureTemplate();
|
| - return TemplateElement.mdvPackage(this).createInstance(model, delegate);
|
| - }
|
| -
|
| - /**
|
| - * The data model which is inherited through the tree.
|
| - * This is only supported if [isTemplate] is true.
|
| - */
|
| - @Experimental()
|
| - get model => TemplateElement.mdvPackage(this).model;
|
| -
|
| - @Experimental()
|
| - void set model(value) {
|
| - _ensureTemplate();
|
| - TemplateElement.mdvPackage(this).model = value;
|
| - }
|
| -
|
| - /**
|
| - * The binding delegate which is inherited through the tree. It can be used
|
| - * to configure custom syntax for `{{bindings}}` inside this template.
|
| - *
|
| - * This is only supported if [isTemplate] is true.
|
| - */
|
| - @Experimental()
|
| - BindingDelegate get bindingDelegate =>
|
| - TemplateElement.mdvPackage(this).bindingDelegate;
|
| -
|
| - @Experimental()
|
| - void set bindingDelegate(BindingDelegate value) {
|
| - _ensureTemplate();
|
| - TemplateElement.mdvPackage(this).bindingDelegate = value;
|
| - }
|
| -
|
| - // TODO(jmesserly): const set would be better
|
| - static const _TABLE_TAGS = const {
|
| - 'caption': null,
|
| - 'col': null,
|
| - 'colgroup': null,
|
| - 'tbody': null,
|
| - 'td': null,
|
| - 'tfoot': null,
|
| - 'th': null,
|
| - 'thead': null,
|
| - 'tr': null,
|
| - };
|
| -
|
| - bool get _isAttributeTemplate => attributes.containsKey('template') &&
|
| - (localName == 'option' || localName == 'optgroup' ||
|
| - _TABLE_TAGS.containsKey(localName));
|
| -
|
| - /**
|
| - * Returns true if this node is a template.
|
| - *
|
| - * A node is a template if [tagName] is TEMPLATE, or the node has the
|
| - * 'template' attribute and this tag supports attribute form for backwards
|
| - * compatibility with existing HTML parsers. The nodes that can use attribute
|
| - * form are table elments (THEAD, TBODY, TFOOT, TH, TR, TD, CAPTION, COLGROUP
|
| - * and COL), OPTION, and OPTGROUP.
|
| - */
|
| - // TODO(jmesserly): this is not a public MDV API, but it seems like a useful
|
| - // place to document which tags our polyfill considers to be templates.
|
| - // Otherwise I'd be repeating it in several other places.
|
| - // See if we can replace this with a TemplateMixin.
|
| - @Experimental()
|
| - bool get isTemplate => tagName == 'TEMPLATE' || _isAttributeTemplate;
|
| -
|
| - void _ensureTemplate() {
|
| - if (!isTemplate) {
|
| - throw new UnsupportedError('$this is not a template.');
|
| - }
|
| - TemplateElement.decorate(this);
|
| - }
|
|
|
| /**
|
| * Access this element's content position.
|
| @@ -13489,9 +13355,6 @@ class HtmlDocument extends Document {
|
| _Utils.register(this, tag, customElementClass, extendsTag);
|
| }
|
|
|
| - // Note: used to polyfill <template>
|
| - Document _templateContentsOwner;
|
| -
|
| @DomName('Document.visibilityChange')
|
| @SupportedBrowser(SupportedBrowser.CHROME)
|
| @SupportedBrowser(SupportedBrowser.FIREFOX)
|
| @@ -19252,27 +19115,6 @@ class _ChildNodeListLazy extends ListBase<Node> {
|
| Node operator[](int index) => _this.childNodes[index];
|
| }
|
|
|
| -/** Information about the instantiated template. */
|
| -class TemplateInstance {
|
| - // TODO(rafaelw): firstNode & lastNode should be read-synchronous
|
| - // in cases where script has modified the template instance boundary.
|
| -
|
| - /** The first node of this template instantiation. */
|
| - final Node firstNode;
|
| -
|
| - /**
|
| - * The last node of this template instantiation.
|
| - * This could be identical to [firstNode] if the template only expanded to a
|
| - * single node.
|
| - */
|
| - final Node lastNode;
|
| -
|
| - /** The model used to instantiate the template. */
|
| - final model;
|
| -
|
| - TemplateInstance(this.firstNode, this.lastNode, this.model);
|
| -}
|
| -
|
|
|
| @DomName('Node')
|
| class Node extends EventTarget {
|
| @@ -19351,52 +19193,6 @@ class Node extends EventTarget {
|
| */
|
| String toString() => nodeValue == null ? super.toString() : nodeValue;
|
|
|
| -
|
| - /**
|
| - * Creates a binding to the attribute [name] to the [path] of the [model].
|
| - *
|
| - * This can be overridden by custom elements to provide the binding used in
|
| - * [Node.bind]. This will only create the binding; it will not add it to
|
| - * [bindings].
|
| - *
|
| - * You should not need to call this directly except from [Node.bind].
|
| - */
|
| - @Experimental()
|
| - createBinding(String name, model, String path) =>
|
| - TemplateElement.mdvPackage(this).createBinding(name, model, path);
|
| -
|
| - /**
|
| - * Binds the attribute [name] to the [path] of the [model].
|
| - * Path is a String of accessors such as `foo.bar.baz`.
|
| - * Returns the `NodeBinding` instance.
|
| - */
|
| - @Experimental()
|
| - bind(String name, model, String path) =>
|
| - TemplateElement.mdvPackage(this).bind(name, model, path);
|
| -
|
| - /** Unbinds the attribute [name]. */
|
| - @Experimental()
|
| - void unbind(String name) {
|
| - TemplateElement.mdvPackage(this).unbind(name);
|
| - }
|
| -
|
| - /** Unbinds all bound attributes. */
|
| - @Experimental()
|
| - void unbindAll() {
|
| - TemplateElement.mdvPackage(this).unbindAll();
|
| - }
|
| -
|
| - /** Gets the data bindings that are associated with this node. */
|
| - @Experimental()
|
| - Map<String, dynamic> get bindings =>
|
| - TemplateElement.mdvPackage(this).bindings;
|
| -
|
| - /** Gets the template instance that instantiated this node, if any. */
|
| - @Experimental()
|
| - TemplateInstance get templateInstance =>
|
| - TemplateElement.mdvPackage(this).templateInstance;
|
| -
|
| -
|
| /**
|
| * Use ownerDocument instead.
|
| */
|
| @@ -24837,88 +24633,6 @@ class TableSectionElement extends HtmlElement {
|
| // WARNING: Do not edit - generated code.
|
|
|
|
|
| -/**
|
| - * Model-Driven Views (MDV)'s native features enables a wide-range of use cases,
|
| - * but (by design) don't attempt to implement a wide array of specialized
|
| - * behaviors.
|
| - *
|
| - * Enabling these features in MDV is a matter of implementing and registering an
|
| - * MDV Custom Syntax. A Custom Syntax is an object which contains one or more
|
| - * delegation functions which implement specialized behavior. This object is
|
| - * registered with MDV via [Element.bindingDelegate]:
|
| - *
|
| - *
|
| - * HTML:
|
| - * <template bind>
|
| - * {{ What!Ever('crazy')->thing^^^I+Want(data) }}
|
| - * </template>
|
| - *
|
| - * Dart:
|
| - * class MySyntax extends BindingDelegate {
|
| - * getBinding(model, path, name, node) {
|
| - * // The magic happens here!
|
| - * }
|
| - * }
|
| - * ...
|
| - * query('template').bindingDelegate = new MySyntax();
|
| - * query('template').model = new MyModel();
|
| - *
|
| - * See <https://github.com/polymer-project/mdv/blob/master/docs/syntax.md> for
|
| - * more information about Custom Syntax.
|
| - */
|
| -// TODO(jmesserly): move this type to the MDV package? Two issues: we'd lose
|
| -// type annotation on [Element.bindingDelegate], and "mdv" is normally imported
|
| -// with a prefix.
|
| -@Experimental()
|
| -abstract class BindingDelegate {
|
| - /**
|
| - * This syntax method allows for a custom interpretation of the contents of
|
| - * mustaches (`{{` ... `}}`).
|
| - *
|
| - * When a template is inserting an instance, it will invoke this method for
|
| - * each mustache which is encountered. The function is invoked with four
|
| - * arguments:
|
| - *
|
| - * - [model]: The data context for which this instance is being created.
|
| - * - [path]: The text contents (trimmed of outer whitespace) of the mustache.
|
| - * - [name]: The context in which the mustache occurs. Within element
|
| - * attributes, this will be the name of the attribute. Within text,
|
| - * this will be 'text'.
|
| - * - [node]: A reference to the node to which this binding will be created.
|
| - *
|
| - * If the method wishes to handle binding, it is required to return an object
|
| - * which has at least a `value` property that can be observed. If it does,
|
| - * then MDV will call [Node.bind on the node:
|
| - *
|
| - * node.bind(name, retval, 'value');
|
| - *
|
| - * If the 'getBinding' does not wish to override the binding, it should return
|
| - * null.
|
| - */
|
| - // TODO(jmesserly): I had to remove type annotations from "name" and "node"
|
| - // Normally they are String and Node respectively. But sometimes it will pass
|
| - // (int name, CompoundBinding node). That seems very confusing; we may want
|
| - // to change this API.
|
| - getBinding(model, String path, name, node) => null;
|
| -
|
| - /**
|
| - * This syntax method allows a syntax to provide an alterate model than the
|
| - * one the template would otherwise use when producing an instance.
|
| - *
|
| - * When a template is about to create an instance, it will invoke this method
|
| - * The function is invoked with two arguments:
|
| - *
|
| - * - [template]: The template element which is about to create and insert an
|
| - * instance.
|
| - * - [model]: The data context for which this instance is being created.
|
| - *
|
| - * The template element will always use the return value of `getInstanceModel`
|
| - * as the model for the new instance. If the syntax does not wish to override
|
| - * the value, it should simply return the `model` value it was passed.
|
| - */
|
| - getInstanceModel(Element template, model) => model;
|
| -}
|
| -
|
| @Experimental()
|
| @DomName('HTMLTemplateElement')
|
| @SupportedBrowser(SupportedBrowser.CHROME)
|
| @@ -24943,207 +24657,8 @@ class TemplateElement extends HtmlElement {
|
|
|
| @DomName('HTMLTemplateElement.content')
|
| @DocsEditable()
|
| - DocumentFragment get _content native "HTMLTemplateElement_content_Getter";
|
| -
|
| + DocumentFragment get content native "HTMLTemplateElement_content_Getter";
|
|
|
| - // For real TemplateElement use the actual DOM .content field instead of
|
| - // our polyfilled expando.
|
| - @Experimental()
|
| - DocumentFragment get content => _content;
|
| -
|
| -
|
| - /**
|
| - * The MDV package, if available.
|
| - *
|
| - * This can be used to initialize MDV support via:
|
| - *
|
| - * import 'dart:html';
|
| - * import 'package:mdv/mdv.dart' as mdv;
|
| - * main() {
|
| - * mdv.initialize();
|
| - * }
|
| - */
|
| - static Function mdvPackage = (node) {
|
| - throw new UnsupportedError("The MDV package is not available. "
|
| - "You can enable it with `import 'package:mdv/mdv.dart' as mdv;` and "
|
| - "`mdv.initialize()`");
|
| - };
|
| -
|
| - /**
|
| - * Ensures proper API and content model for template elements.
|
| - *
|
| - * [instanceRef] can be used to set the [Element.ref] property of [template],
|
| - * and use the ref's content will be used as source when createInstance() is
|
| - * invoked.
|
| - *
|
| - * Returns true if this template was just decorated, or false if it was
|
| - * already decorated.
|
| - */
|
| - @Experimental()
|
| - static bool decorate(Element template, [Element instanceRef]) {
|
| - // == true check because it starts as a null field.
|
| - if (template._templateIsDecorated == true) return false;
|
| -
|
| - _injectStylesheet();
|
| -
|
| - var templateElement = template;
|
| - templateElement._templateIsDecorated = true;
|
| - var isNative = templateElement is TemplateElement;
|
| - var bootstrapContents = isNative;
|
| - var liftContents = !isNative;
|
| - var liftRoot = false;
|
| -
|
| - if (!isNative && templateElement._isAttributeTemplate) {
|
| - if (instanceRef != null) {
|
| - // TODO(jmesserly): this is just an assert in MDV.
|
| - throw new ArgumentError('instanceRef should not be supplied for '
|
| - 'attribute templates.');
|
| - }
|
| - templateElement = _extractTemplateFromAttributeTemplate(template);
|
| - templateElement._templateIsDecorated = true;
|
| - isNative = templateElement is TemplateElement;
|
| - liftRoot = true;
|
| - }
|
| -
|
| - if (!isNative) {
|
| - var doc = _getTemplateContentsOwner(templateElement.ownerDocument);
|
| - templateElement._templateContent = doc.createDocumentFragment();
|
| - }
|
| -
|
| - if (instanceRef != null) {
|
| - // template is contained within an instance, its direct content must be
|
| - // empty
|
| - templateElement._templateInstanceRef = instanceRef;
|
| - } else if (liftContents) {
|
| - _liftNonNativeChildrenIntoContent(templateElement, template, liftRoot);
|
| - } else if (bootstrapContents) {
|
| - bootstrap(templateElement.content);
|
| - }
|
| -
|
| - return true;
|
| - }
|
| -
|
| - // http://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/templates/index.html#dfn-template-contents-owner
|
| - static Document _getTemplateContentsOwner(HtmlDocument doc) {
|
| - if (doc.window == null) {
|
| - return doc;
|
| - }
|
| - var d = doc._templateContentsOwner;
|
| - if (d == null) {
|
| - // TODO(arv): This should either be a Document or HTMLDocument depending
|
| - // on doc.
|
| - d = doc.implementation.createHtmlDocument('');
|
| - while (d.lastChild != null) {
|
| - d.lastChild.remove();
|
| - }
|
| - doc._templateContentsOwner = d;
|
| - }
|
| - return d;
|
| - }
|
| -
|
| - // For non-template browsers, the parser will disallow <template> in certain
|
| - // locations, so we allow "attribute templates" which combine the template
|
| - // element with the top-level container node of the content, e.g.
|
| - //
|
| - // <tr template repeat="{{ foo }}"" class="bar"><td>Bar</td></tr>
|
| - //
|
| - // becomes
|
| - //
|
| - // <template repeat="{{ foo }}">
|
| - // + #document-fragment
|
| - // + <tr class="bar">
|
| - // + <td>Bar</td>
|
| - //
|
| - static Element _extractTemplateFromAttributeTemplate(Element el) {
|
| - var template = el.ownerDocument.createElement('template');
|
| - el.parentNode.insertBefore(template, el);
|
| -
|
| - for (var name in el.attributes.keys.toList()) {
|
| - switch (name) {
|
| - case 'template':
|
| - el.attributes.remove(name);
|
| - break;
|
| - case 'repeat':
|
| - case 'bind':
|
| - case 'ref':
|
| - template.attributes[name] = el.attributes.remove(name);
|
| - break;
|
| - }
|
| - }
|
| -
|
| - return template;
|
| - }
|
| -
|
| - static void _liftNonNativeChildrenIntoContent(Element template, Element el,
|
| - bool useRoot) {
|
| -
|
| - var content = template.content;
|
| - if (useRoot) {
|
| - content.append(el);
|
| - return;
|
| - }
|
| -
|
| - var child;
|
| - while ((child = el.firstChild) != null) {
|
| - content.append(child);
|
| - }
|
| - }
|
| -
|
| - /**
|
| - * This used to decorate recursively all templates from a given node.
|
| - *
|
| - * By default [decorate] will be called on templates lazily when certain
|
| - * properties such as [model] are accessed, but it can be run eagerly to
|
| - * decorate an entire tree recursively.
|
| - */
|
| - // TODO(rafaelw): Review whether this is the right public API.
|
| - @Experimental()
|
| - static void bootstrap(Node content) {
|
| - void _bootstrap(template) {
|
| - if (!TemplateElement.decorate(template)) {
|
| - bootstrap(template.content);
|
| - }
|
| - }
|
| -
|
| - // Need to do this first as the contents may get lifted if |node| is
|
| - // template.
|
| - // TODO(jmesserly): content is DocumentFragment or Element
|
| - var descendents =
|
| - (content as dynamic).querySelectorAll(_allTemplatesSelectors);
|
| - if (content is Element && (content as Element).isTemplate) {
|
| - _bootstrap(content);
|
| - }
|
| -
|
| - descendents.forEach(_bootstrap);
|
| - }
|
| -
|
| - static final String _allTemplatesSelectors =
|
| - 'template, option[template], optgroup[template], ' +
|
| - Element._TABLE_TAGS.keys.map((k) => "$k[template]").join(", ");
|
| -
|
| - static bool _initStyles;
|
| -
|
| - static void _injectStylesheet() {
|
| - if (_initStyles == true) return;
|
| - _initStyles = true;
|
| -
|
| - var style = new StyleElement();
|
| - style.text = r'''
|
| -template,
|
| -thead[template],
|
| -tbody[template],
|
| -tfoot[template],
|
| -th[template],
|
| -tr[template],
|
| -td[template],
|
| -caption[template],
|
| -colgroup[template],
|
| -col[template],
|
| -option[template] {
|
| - display: none;
|
| -}''';
|
| - document.head.append(style);
|
| - }
|
|
|
| /**
|
| * An override to place the contents into content rather than as child nodes.
|
|
|