Commit 0a1bc580 authored by khorimoto's avatar khorimoto Committed by Commit bot

If shadow DOM is not supported, search for i18n attributes without using the /deep/ selector.

This fixes an issue where Chrome on iOS failed to translate interstitial pages due to use of this selector (on iOS, Chrome uses UIWebView which does not have native support for shadow DOM).

Note that Polymer-based pages will still work in iOS WebUI pages because /deep/ will be polyfilled.

BUG=474360

Review URL: https://codereview.chromium.org/1062813007

Cr-Commit-Position: refs/heads/master@{#324179}
parent 615d7998
...@@ -111,7 +111,14 @@ var i18nTemplate = (function() { ...@@ -111,7 +111,14 @@ var i18nTemplate = (function() {
}; };
var attributeNames = Object.keys(handlers); var attributeNames = Object.keys(handlers);
var selector = 'html /deep/ [' + attributeNames.join('],[') + ']'; // Chrome for iOS must use Apple's UIWebView, which (as of April 2015) does
// not have native shadow DOM support. If shadow DOM is supported (or
// polyfilled), search for i18n attributes using the /deep/ selector;
// otherwise, do not attempt to search within the shadow DOM.
var selector =
(window.document.body && window.document.body.createShadowRoot) ?
'html /deep/ [' + attributeNames.join('],[') + ']' :
'[' + attributeNames.join('],[') + ']';
/** /**
* Processes a DOM tree with the {@code dictionary} map. * Processes a DOM tree with the {@code dictionary} map.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment