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 b2b4188691dbb051b438e5a74241751b72eb9c6d..c8fd179a1b564f10c9232d48c14fb2cdaf022d7d 100644 |
--- a/tools/dom/templates/html/impl/impl_Element.darttemplate |
+++ b/tools/dom/templates/html/impl/impl_Element.darttemplate |
@@ -1037,7 +1037,7 @@ $endif |
if (treeSanitizer is _TrustedHtmlTreeSanitizer) { |
_insertAdjacentHtml(where, html); |
} else { |
- _insertAdjacentNode(where, new DocumentFragment.html(html, |
+ _insertAdjacentNode(where, createFragment(html, |
validator: validator, treeSanitizer: treeSanitizer)); |
} |
} |
@@ -1328,11 +1328,6 @@ $endif |
if (_parseDocument == null) { |
_parseDocument = document.implementation.createHtmlDocument(''); |
_parseRange = _parseDocument.createRange(); |
- |
- // Workaround for Chrome bug 229142- URIs are not resolved in new doc. |
- var base = _parseDocument.createElement('base'); |
- base.href = document.baseUri; |
- _parseDocument.head.append(base); |
} |
var contextElement; |
if (this is BodyElement) { |
@@ -1342,7 +1337,8 @@ $endif |
_parseDocument.body.append(contextElement); |
} |
var fragment; |
- if (Range.supportsCreateContextualFragment) { |
+ if (Range.supportsCreateContextualFragment && |
+ _canBeUsedToCreateContextualFragment) { |
_parseRange.selectNodeContents(contextElement); |
fragment = _parseRange.createContextualFragment(html); |
} else { |
@@ -1364,6 +1360,24 @@ $endif |
return fragment; |
} |
+ /** Test if createContextualFragment is supported for this element type */ |
+ bool get _canBeUsedToCreateContextualFragment => |
+ !_cannotBeUsedToCreateContextualFragment; |
+ |
+ /** Test if createContextualFragment is NOT supported for this element type */ |
+ bool get _cannotBeUsedToCreateContextualFragment => |
+ _tagsForWhichCreateContextualFragmentIsNotSupported.contains(tagName); |
+ |
+ /** |
+ * A hard-coded list of the tag names for which createContextualFragment |
+ * isn't supported. |
+ */ |
+ static const _tagsForWhichCreateContextualFragmentIsNotSupported = |
+ const ['HEAD', 'AREA', |
+ 'BASE', 'BASEFONT', 'BR', 'COL', 'COLGROUP', 'EMBED', 'FRAME', 'FRAMESET', |
+ 'HR', 'IMAGE', 'IMG', 'INPUT', 'ISINDEX', 'LINK', 'META', 'PARAM', |
+ 'SOURCE', 'STYLE', 'TITLE', 'WBR']; |
+ |
/** |
* Parses the HTML fragment and sets it as the contents of this element. |
* |