Commit f8d77eb1 authored by rbpotter's avatar rbpotter Committed by Commit Bot

Polymer modulizer: Support ignore annotations

Support /* ignore */ annotations in Polymer modulizer, following the
same approach as the JS modulizer. This will be used to temporarily
migrate settings_idle_load and settings pages that depend on it, before
adding lazy loading to the Polymer 3 page.

Bug: 1026426
Change-Id: Iaf2b3d1e3ba69f97946039522d86ecf2739370cc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2092183Reviewed-by: default avatardpapad <dpapad@chromium.org>
Commit-Queue: Rebekah Potter <rbpotter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#747951}
parent 0224aef4
......@@ -351,6 +351,9 @@ def _process_dom_module(js_file, html_file):
# Replace export annotations with 'export'.
EXPORT_LINE_REGEX = '/* #export */'
# Ignore lines with an ignore annotation.
IGNORE_LINE_REGEX = '\s*/\* #ignore \*/(\S|\s)*'
with io.open(js_file, encoding='utf-8') as f:
lines = f.readlines()
......@@ -393,6 +396,9 @@ def _process_dom_module(js_file, html_file):
cr_define_end_line = i
break
if re.match(IGNORE_LINE_REGEX, line):
line = ''
line = _rewrite_namespaces(line)
lines[i] = line
......
......@@ -76,6 +76,13 @@ class PolymerModulizerTest(unittest.TestCase):
'dom-module', 'dom_module.html', 'dom_module_with_define.js',
'dom_module_with_define.m.js', 'dom_module_with_define_expected.js')
# Test case where HTML is extracted from a Polymer2 <dom-module> that has
# ignore annotations.
def testDomModuleWithIgnore(self):
self._run_test('dom-module', 'dom_module.html', 'dom_module_with_ignore.js',
'dom_module_with_ignore.m.js',
'dom_module_with_ignore_expected.js')
# Test case where HTML is extracted from a Polymer2 <dom-module> that also
# uses <if expr> for imports.
def testDomModuleWithConditionalImport(self):
......
Polymer({
is: 'cr-test-foo',
behaviors: [Polymer.PaperRippleBehavior],
/** @override */
ready() {
/* #ignore */ this.importHref('./foo.html');
},
});
import {Polymer, html} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
import {PaperRippleBehavior} from 'chrome://resources/polymer/v3_0/paper-behaviors/paper-ripple-behavior.js';
// import 'chrome://resources/js/ignore_me.m.js';
import '../shared_vars_css.m.js';
import './foo.m.js';
Polymer({
_template: html`<!--_html_template_start_-->
<style>
div {
font-size: 2rem;
}
</style>
<div>Hello world</div>
<!--_html_template_end_-->`,
is: 'cr-test-foo',
behaviors: [PaperRippleBehavior],
/** @override */
ready() {
},
});
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