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 90917bb4590c68b169f6499ab246c4ef211c6fc6..4cc90adf80c4289040b1e2ac95d471843299d79c 100644 |
--- a/sdk/lib/html/dart2js/html_dart2js.dart |
+++ b/sdk/lib/html/dart2js/html_dart2js.dart |
@@ -12898,7 +12898,7 @@ abstract class Element extends Node implements GlobalEventHandlers, ParentNode, |
if (treeSanitizer is _TrustedHtmlTreeSanitizer) { |
_insertAdjacentHtml(where, html); |
} else { |
- _insertAdjacentNode(where, new DocumentFragment.html(html, |
+ _insertAdjacentNode(where, createFragment(html, |
validator: validator, treeSanitizer: treeSanitizer)); |
} |
} |
@@ -13181,11 +13181,6 @@ abstract class Element extends Node implements GlobalEventHandlers, ParentNode, |
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) { |
@@ -13195,7 +13190,8 @@ abstract class Element extends Node implements GlobalEventHandlers, ParentNode, |
_parseDocument.body.append(contextElement); |
} |
var fragment; |
- if (Range.supportsCreateContextualFragment) { |
+ if (Range.supportsCreateContextualFragment && |
+ _canBeUsedToCreateContextualFragment) { |
_parseRange.selectNodeContents(contextElement); |
fragment = _parseRange.createContextualFragment(html); |
} else { |
@@ -13217,6 +13213,24 @@ abstract class Element extends Node implements GlobalEventHandlers, ParentNode, |
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. |
* |