| Index: tools/dom/templates/html/impl/impl_Element.darttemplate
|
| diff --git a/tools/dom/templates/html/impl/impl_Element.darttemplate b/tools/dom/templates/html/impl/impl_Element.darttemplate
|
| index ecc640eeca3a073b08f2ba4456291cc962567b21..8e4757c36b6aa766d6aaee104fee6cc05387815a 100644
|
| --- a/tools/dom/templates/html/impl/impl_Element.darttemplate
|
| +++ b/tools/dom/templates/html/impl/impl_Element.darttemplate
|
| @@ -676,6 +676,7 @@ $endif
|
|
|
| bool _templateIsDecorated;
|
|
|
| +
|
| /**
|
| * Gets the template this node refers to.
|
| * This is only supported if [isTemplate] is true.
|
| @@ -687,7 +688,19 @@ $endif
|
| 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;
|
| @@ -740,7 +753,8 @@ $endif
|
| };
|
|
|
| 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.
|
| @@ -749,7 +763,7 @@ $endif
|
| * '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.
|
|
|