Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Unified Diff: sdk/lib/html/dartium/html_dartium.dart

Side-by-side diff isn't available for this file because of its large size.
Issue 1221043003: appendHtml, when sanitizing, should create document fragment in the right context (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: One more try. Suppress invalid co19 tests. Slight code cleanup. Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
Download patch
« no previous file with comments | « sdk/lib/html/dart2js/html_dart2js.dart ('k') | tests/co19/co19-dart2js.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 8eb08da6c67246d4c000738e3e85013a43403dce..c837e3fcc3a4547050bb63a92750d2ee6fb34569 100644
--- a/sdk/lib/html/dartium/html_dartium.dart
+++ b/sdk/lib/html/dartium/html_dartium.dart
@@ -13670,7 +13670,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));
}
}
@@ -13873,11 +13873,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) {
@@ -13887,7 +13882,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 {
@@ -13909,6 +13905,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.
*
« no previous file with comments | « sdk/lib/html/dart2js/html_dart2js.dart ('k') | tests/co19/co19-dart2js.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698