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

Unified Diff: ui/webui/resources/js/i18n_template_no_process.js

Issue 1234753002: Revert "Teach i18nTemplate.process() to handle <link rel=import> and <template>" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/webui/resources/js/compiled_resources2.gyp ('k') | ui/webui/resources/js/webui_resource_test.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/webui/resources/js/i18n_template_no_process.js
diff --git a/ui/webui/resources/js/i18n_template_no_process.js b/ui/webui/resources/js/i18n_template_no_process.js
index d009ce35de470525c85cd558a509f7ce2c8a497f..44262810b0328671273ec433f4b6a5b0f2c24496 100644
--- a/ui/webui/resources/js/i18n_template_no_process.js
+++ b/ui/webui/resources/js/i18n_template_no_process.js
@@ -26,7 +26,6 @@
*/
var i18nTemplate = (function() {
- 'use strict';
/**
* This provides the handlers for the templating engine. The key is used as
* the attribute name and the value is the function that gets called for every
@@ -112,32 +111,21 @@ var i18nTemplate = (function() {
};
var attributeNames = Object.keys(handlers);
- var selector = '[' + 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.
- * @param {Document|DocumentFragment|Element} root The root of the DOM tree to
- * process.
+ * @param {Document|Element} root The root of the DOM tree to process.
* @param {LoadTimeData} dictionary The dictionary to draw from.
*/
function process(root, dictionary) {
- var importLinks = root.querySelectorAll('link[rel=import]');
- for (var i = 0; i < importLinks.length; ++i) {
- var importLink = /** @type {!HTMLLinkElement} */(importLinks[i]);
- if (!importLink.import) {
- // Happens when a <link rel=import> is inside a <template>.
- // TODO(dbeam): should we log an error if we detect that here?
- continue;
- }
- process(importLink.import, dictionary);
- }
-
- var templates = root.querySelectorAll('template');
- for (var i = 0; i < templates.length; ++i) {
- var template = /** @type {HTMLTemplateElement} */(templates[i]);
- process(template.content, dictionary);
- }
-
var elements = root.querySelectorAll(selector);
for (var element, i = 0; element = elements[i]; i++) {
for (var j = 0; j < attributeNames.length; j++) {
@@ -147,9 +135,8 @@ var i18nTemplate = (function() {
handlers[name](element, attribute, dictionary);
}
}
-
var doc = root instanceof Document ? root : root.ownerDocument;
- if (doc && doc.documentElement)
+ if (doc)
doc.documentElement.classList.add('i18n-processed');
}
« no previous file with comments | « ui/webui/resources/js/compiled_resources2.gyp ('k') | ui/webui/resources/js/webui_resource_test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698