| Index: sdk/lib/html/dart2js/html_dart2js.dart
|
| diff --git a/sdk/lib/html/dart2js/html_dart2js.dart b/sdk/lib/html/dart2js/html_dart2js.dart
|
| index 47a6611f970536e54cc83eabac94d059503ef5b2..8e307a41ff76ac3b206261f3a336c7ccebdf9c08 100644
|
| --- a/sdk/lib/html/dart2js/html_dart2js.dart
|
| +++ b/sdk/lib/html/dart2js/html_dart2js.dart
|
| @@ -8288,6 +8288,7 @@ abstract class Element extends Node implements ElementTraversal native "Element"
|
|
|
| bool _templateIsDecorated;
|
|
|
| +
|
| /**
|
| * Gets the template this node refers to.
|
| * This is only supported if [isTemplate] is true.
|
| @@ -8299,7 +8300,19 @@ abstract class Element extends Node implements ElementTraversal native "Element"
|
| Element ref = null;
|
| var refId = attributes['ref'];
|
| if (refId != null) {
|
| - ref = document.getElementById(refId);
|
| + 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) {
|
| +
|
| + ref = treeScope.getElementById(refId);
|
| + }
|
| }
|
|
|
| return ref != null ? ref : _templateInstanceRef;
|
| @@ -8352,7 +8365,8 @@ abstract class Element extends Node implements ElementTraversal native "Element"
|
| };
|
|
|
| bool get _isAttributeTemplate => attributes.containsKey('template') &&
|
| - (localName == 'option' || _TABLE_TAGS.containsKey(localName));
|
| + (localName == 'option' || localName == 'optgroup' ||
|
| + _TABLE_TAGS.containsKey(localName));
|
|
|
| /**
|
| * Returns true if this node is a template.
|
| @@ -8361,7 +8375,7 @@ abstract class Element extends Node implements ElementTraversal native "Element"
|
| * '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) and OPTION.
|
| + * 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.
|
| @@ -21128,7 +21142,8 @@ class TemplateElement extends _HTMLElement native "HTMLTemplateElement" {
|
| descendents.forEach(_bootstrap);
|
| }
|
|
|
| - static final String _allTemplatesSelectors = 'template, option[template], ' +
|
| + static final String _allTemplatesSelectors =
|
| + 'template, option[template], optgroup[template], ' +
|
| Element._TABLE_TAGS.keys.map((k) => "$k[template]").join(", ");
|
|
|
| static bool _initStyles;
|
|
|