Skip to content

Commit

Permalink
WebUI: Fix migrated_imports for ui/webui/resources/html URLs.
Browse files Browse the repository at this point in the history
This fix unblocks [1] to use the
chrome://resources/html/plural_string_proxy.html URL in
polymer_modulizer()'s |migrated_imports| parameter.

[1] https://chromium-review.googlesource.com/c/chromium/src/+/2741118

Bug: 950041
Change-Id: I9bff52d5dddc7fe9a192afd0622d276f9aa932a1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2748494
Auto-Submit: dpapad <dpapad@chromium.org>
Commit-Queue: Rebekah Potter <rbpotter@chromium.org>
Reviewed-by: Rebekah Potter <rbpotter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#861606}
  • Loading branch information
freshp86 authored and Chromium LUCI CQ committed Mar 10, 2021
1 parent 889b043 commit 6c4f91a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
7 changes: 4 additions & 3 deletions tools/polymer/polymer.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,14 @@ def _to_js_normalized(self):
self.input_scheme = 'chrome'
return POLYMER_V3_DIR + 'polymer/polymer_bundled.min.js'

extension = ('.js'
if self.html_path_normalized in _migrated_imports else '.m.js')

if re.match(r'ui/webui/resources/html/', self.html_path_normalized):
return (self.html_path_normalized
.replace(r'ui/webui/resources/html/', 'ui/webui/resources/js/')
.replace(r'.html', '.m.js'))
.replace(r'.html', extension))

extension = (
'.js' if self.html_path_normalized in _migrated_imports else '.m.js')
return self.html_path_normalized.replace(r'.html', extension)

def _to_js(self):
Expand Down
1 change: 1 addition & 0 deletions tools/polymer/polymer_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ def testDomModuleWithMigratedImports(self):
self._additional_flags = [
'--migrated_imports',
'tools/polymer/tests/foo.html',
'ui/webui/resources/html/ignore_me.html',
]
self._run_test('dom-module', 'dom_module.html', 'dom_module.js',
'dom_module.m.js',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {Polymer, html} from '//resources/polymer/v3_0/polymer/polymer_bundled.min.js';

import {PaperRippleBehavior} from '//resources/polymer/v3_0/paper-behaviors/paper-ripple-behavior.js';
import '//resources/js/ignore_me.m.js';
import '//resources/js/ignore_me.js';
import '../shared_vars_css.m.js';
import './foo.js';

Expand Down

0 comments on commit 6c4f91a

Please sign in to comment.