Update some .html files to match the polymer-modulizer expectations
This change includes the following updates: * Script tags are moved out of dom-module element * <template strip-whitespaces> is changed to <template> * gr-js-api-interface.html is splitted to avoid <script...> after <dom-module> * gr-app initialization moved to a separate file. Without this change polymer-modulizer places initialization code after other imports * gr-external-style - move importHref in a separate _importHref method. It is not possible to mock Polymer.importHref method in tests after conversion to ES6 modules. Change-Id: I97bae910c5d0df1bf8e6778657173729f0a6652a
This commit is contained in:
parent
a4224ac50f
commit
31f655eb15
@ -25,7 +25,7 @@ limitations under the License.
|
||||
<link rel="import" href="../../shared/gr-limited-text/gr-limited-text.html">
|
||||
|
||||
<dom-module id="gr-change-requirements">
|
||||
<template strip-whitespace>
|
||||
<template>
|
||||
<style include="shared-styles">
|
||||
:host {
|
||||
display: table;
|
||||
|
@ -23,12 +23,12 @@ limitations under the License.
|
||||
<link rel="import" href="../../core/gr-navigation/gr-navigation.html">
|
||||
<link rel="import" href="../../shared/gr-rest-api-interface/gr-rest-api-interface.html">
|
||||
<link rel="import" href="../gr-reporting/gr-reporting.html">
|
||||
<script src="/bower_components/page/page.js"></script>
|
||||
|
||||
<dom-module id="gr-router">
|
||||
<template>
|
||||
<gr-rest-api-interface id="restAPI"></gr-rest-api-interface>
|
||||
<gr-reporting id="reporting"></gr-reporting>
|
||||
</template>
|
||||
<script src="/bower_components/page/page.js"></script>
|
||||
<script src="gr-router.js"></script>
|
||||
</dom-module>
|
||||
|
@ -16,10 +16,11 @@ limitations under the License.
|
||||
-->
|
||||
|
||||
<link rel="import" href="/bower_components/polymer/polymer.html">
|
||||
<script src="../../../types/types.js"></script>
|
||||
<script src="../gr-diff-highlight/gr-annotation.js"></script>
|
||||
|
||||
<dom-module id="gr-coverage-layer">
|
||||
<template>
|
||||
</template>
|
||||
<script src="../../../types/types.js"></script>
|
||||
<script src="../gr-diff-highlight/gr-annotation.js"></script>
|
||||
<script src="gr-coverage-layer.js"></script>
|
||||
</dom-module>
|
||||
|
@ -20,6 +20,15 @@ limitations under the License.
|
||||
<link rel="import" href="../gr-diff-processor/gr-diff-processor.html">
|
||||
<link rel="import" href="../../../elements/shared/gr-hovercard/gr-hovercard.html">
|
||||
<link rel="import" href="../gr-ranged-comment-layer/gr-ranged-comment-layer.html">
|
||||
<script src="../../../scripts/util.js"></script>
|
||||
<script src="../gr-diff/gr-diff-line.js"></script>
|
||||
<script src="../gr-diff/gr-diff-group.js"></script>
|
||||
<script src="../gr-diff-highlight/gr-annotation.js"></script>
|
||||
<script src="gr-diff-builder.js"></script>
|
||||
<script src="gr-diff-builder-side-by-side.js"></script>
|
||||
<script src="gr-diff-builder-unified.js"></script>
|
||||
<script src="gr-diff-builder-image.js"></script>
|
||||
<script src="gr-diff-builder-binary.js"></script>
|
||||
|
||||
<dom-module id="gr-diff-builder">
|
||||
<template>
|
||||
@ -41,14 +50,5 @@ limitations under the License.
|
||||
id="processor"
|
||||
groups="{{_groups}}"></gr-diff-processor>
|
||||
</template>
|
||||
<script src="../../../scripts/util.js"></script>
|
||||
<script src="../gr-diff/gr-diff-line.js"></script>
|
||||
<script src="../gr-diff/gr-diff-group.js"></script>
|
||||
<script src="../gr-diff-highlight/gr-annotation.js"></script>
|
||||
<script src="gr-diff-builder.js"></script>
|
||||
<script src="gr-diff-builder-side-by-side.js"></script>
|
||||
<script src="gr-diff-builder-unified.js"></script>
|
||||
<script src="gr-diff-builder-image.js"></script>
|
||||
<script src="gr-diff-builder-binary.js"></script>
|
||||
<script src="gr-diff-builder-element.js"></script>
|
||||
</dom-module>
|
||||
|
@ -19,6 +19,8 @@ limitations under the License.
|
||||
<link rel="import" href="../../../behaviors/fire-behavior/fire-behavior.html">
|
||||
<link rel="import" href="../../../styles/shared-styles.html">
|
||||
<link rel="import" href="../gr-selection-action-box/gr-selection-action-box.html">
|
||||
<script src="gr-annotation.js"></script>
|
||||
<script src="gr-range-normalizer.js"></script>
|
||||
|
||||
<dom-module id="gr-diff-highlight">
|
||||
<template>
|
||||
@ -38,7 +40,5 @@ limitations under the License.
|
||||
<slot></slot>
|
||||
</div>
|
||||
</template>
|
||||
<script src="gr-annotation.js"></script>
|
||||
<script src="gr-range-normalizer.js"></script>
|
||||
<script src="gr-diff-highlight.js"></script>
|
||||
</dom-module>
|
||||
|
@ -16,11 +16,10 @@ limitations under the License.
|
||||
-->
|
||||
|
||||
<link rel="import" href="/bower_components/polymer/polymer.html">
|
||||
<script src="../gr-diff/gr-diff-line.js"></script>
|
||||
<script src="../gr-diff/gr-diff-group.js"></script>
|
||||
<script src="../../../scripts/util.js"></script>
|
||||
|
||||
<dom-module id="gr-diff-processor">
|
||||
<script src="../gr-diff/gr-diff-line.js"></script>
|
||||
<script src="../gr-diff/gr-diff-group.js"></script>
|
||||
|
||||
<script src="../../../scripts/util.js"></script>
|
||||
<script src="gr-diff-processor.js"></script>
|
||||
</dom-module>
|
||||
|
@ -18,6 +18,7 @@ limitations under the License.
|
||||
<link rel="import" href="../../../behaviors/dom-util-behavior/dom-util-behavior.html">
|
||||
<link rel="import" href="../../../styles/shared-styles.html">
|
||||
<script src="../../../scripts/util.js"></script>
|
||||
<script src="../gr-diff-highlight/gr-range-normalizer.js"></script>
|
||||
|
||||
<dom-module id="gr-diff-selection">
|
||||
<template>
|
||||
@ -25,6 +26,5 @@ limitations under the License.
|
||||
<slot></slot>
|
||||
</div>
|
||||
</template>
|
||||
<script src="../gr-diff-highlight/gr-range-normalizer.js"></script>
|
||||
<script src="gr-diff-selection.js"></script>
|
||||
</dom-module>
|
||||
|
@ -27,6 +27,8 @@ limitations under the License.
|
||||
<link rel="import" href="../gr-ranged-comment-themes/gr-ranged-comment-theme.html">
|
||||
|
||||
<script src="../../../scripts/hiddenscroll.js"></script>
|
||||
<script src="gr-diff-line.js"></script>
|
||||
<script src="gr-diff-group.js"></script>
|
||||
|
||||
<dom-module id="gr-diff">
|
||||
<template>
|
||||
@ -423,7 +425,5 @@ limitations under the License.
|
||||
</gr-button>
|
||||
</div>
|
||||
</template>
|
||||
<script src="gr-diff-line.js"></script>
|
||||
<script src="gr-diff-group.js"></script>
|
||||
<script src="gr-diff.js"></script>
|
||||
</dom-module>
|
||||
|
@ -16,9 +16,10 @@ limitations under the License.
|
||||
-->
|
||||
|
||||
<link rel="import" href="/bower_components/polymer/polymer.html">
|
||||
<script src="../gr-diff-highlight/gr-annotation.js"></script>
|
||||
|
||||
<dom-module id="gr-ranged-comment-layer">
|
||||
<template>
|
||||
</template>
|
||||
<script src="../gr-diff-highlight/gr-annotation.js"></script>
|
||||
<script src="gr-ranged-comment-layer.js"></script>
|
||||
</dom-module>
|
||||
|
@ -16,13 +16,13 @@ limitations under the License.
|
||||
-->
|
||||
<link rel="import" href="/bower_components/polymer/polymer.html">
|
||||
<link rel="import" href="../../shared/gr-lib-loader/gr-lib-loader.html">
|
||||
<script src="../../../scripts/util.js"></script>
|
||||
<script src="../gr-diff/gr-diff-line.js"></script>
|
||||
<script src="../gr-diff-highlight/gr-annotation.js"></script>
|
||||
|
||||
<dom-module id="gr-syntax-layer">
|
||||
<template>
|
||||
<gr-lib-loader id="libLoader"></gr-lib-loader>
|
||||
</template>
|
||||
<script src="../../../scripts/util.js"></script>
|
||||
<script src="../gr-diff/gr-diff-line.js"></script>
|
||||
<script src="../gr-diff-highlight/gr-annotation.js"></script>
|
||||
<script src="gr-syntax-layer.js"></script>
|
||||
</dom-module>
|
||||
|
24
polygerrit-ui/app/elements/gr-app-init.js
Normal file
24
polygerrit-ui/app/elements/gr-app-init.js
Normal file
@ -0,0 +1,24 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
if (!window.Polymer) {
|
||||
window.Polymer = {
|
||||
passiveTouchGestures: true,
|
||||
lazyRegister: true,
|
||||
};
|
||||
}
|
||||
window.Gerrit = window.Gerrit || {};
|
@ -14,15 +14,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<script>
|
||||
if (!window.Polymer) {
|
||||
window.Polymer = {
|
||||
passiveTouchGestures: true,
|
||||
lazyRegister: true,
|
||||
};
|
||||
}
|
||||
window.Gerrit = window.Gerrit || {};
|
||||
</script>
|
||||
<script src="gr-app-init.js"></script>
|
||||
<script src="./font-roboto-local-loader.js" type="module" />
|
||||
|
||||
<link rel="import" href="/bower_components/polymer/polymer.html">
|
||||
|
@ -19,7 +19,7 @@ limitations under the License.
|
||||
<link rel="import" href="../../shared/gr-js-api-interface/gr-js-api-interface.html">
|
||||
|
||||
<dom-module id="gr-endpoint-decorator">
|
||||
<template strip-whitespace>
|
||||
<template>
|
||||
<slot></slot>
|
||||
</template>
|
||||
<script src="gr-endpoint-decorator.js"></script>
|
||||
|
@ -37,6 +37,12 @@
|
||||
};
|
||||
}
|
||||
|
||||
_importHref(url, resolve, reject) {
|
||||
// It is impossible to mock es6-module imported function.
|
||||
// The _importHref function is mocked in test.
|
||||
Polymer.importHref(url, resolve, reject);
|
||||
}
|
||||
|
||||
/**
|
||||
* @suppress {checkTypes}
|
||||
*/
|
||||
@ -44,7 +50,7 @@
|
||||
if (this._urlsImported.includes(url)) { return Promise.resolve(); }
|
||||
this._urlsImported.push(url);
|
||||
return new Promise((resolve, reject) => {
|
||||
Polymer.importHref(url, resolve, reject);
|
||||
this._importHref(url, resolve, reject);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -41,6 +41,7 @@ limitations under the License.
|
||||
let sandbox;
|
||||
let element;
|
||||
let plugin;
|
||||
let importHrefStub;
|
||||
|
||||
const installPlugin = () => {
|
||||
if (plugin) { return; }
|
||||
@ -74,7 +75,12 @@ limitations under the License.
|
||||
|
||||
setup(() => {
|
||||
sandbox = sinon.sandbox.create();
|
||||
sandbox.stub(Polymer, 'importHref', (url, resolve) => resolve());
|
||||
importHrefStub = sandbox.stub().callsArg(1);
|
||||
stub('gr-external-style', {
|
||||
_importHref: (url, resolve, reject) => {
|
||||
importHrefStub(url, resolve, reject);
|
||||
},
|
||||
});
|
||||
sandbox.stub(Gerrit, 'awaitPluginsLoaded').returns(Promise.resolve());
|
||||
});
|
||||
|
||||
@ -85,7 +91,7 @@ limitations under the License.
|
||||
test('imports plugin-provided module', async () => {
|
||||
lateRegister();
|
||||
await new Promise(flush);
|
||||
assert.isTrue(Polymer.importHref.calledWith(new URL(TEST_URL)));
|
||||
assert.isTrue(importHrefStub.calledWith(new URL(TEST_URL)));
|
||||
});
|
||||
|
||||
test('applies plugin-provided styles', async () => {
|
||||
@ -117,7 +123,7 @@ limitations under the License.
|
||||
test('loads and applies preloaded modules', async () => {
|
||||
earlyRegister();
|
||||
await new Promise(flush);
|
||||
assert.isTrue(Polymer.importHref.calledWith(new URL(TEST_URL)));
|
||||
assert.isTrue(importHrefStub.calledWith(new URL(TEST_URL)));
|
||||
assert.isTrue(element._applyStyle.calledWith('some-module'));
|
||||
});
|
||||
});
|
||||
|
@ -44,6 +44,7 @@ limitations under the License.
|
||||
<link rel="import" href="../gr-menu-editor/gr-menu-editor.html">
|
||||
<link rel="import" href="../gr-ssh-editor/gr-ssh-editor.html">
|
||||
<link rel="import" href="../gr-watched-projects-editor/gr-watched-projects-editor.html">
|
||||
<script src="../../../scripts/util.js"></script>
|
||||
|
||||
<dom-module id="gr-settings-view">
|
||||
<template>
|
||||
@ -517,6 +518,5 @@ limitations under the License.
|
||||
</div>
|
||||
<gr-rest-api-interface id="restAPI"></gr-rest-api-interface>
|
||||
</template>
|
||||
<script src="../../../scripts/util.js"></script>
|
||||
<script src="gr-settings-view.js"></script>
|
||||
</dom-module>
|
||||
|
@ -22,6 +22,7 @@ limitations under the License.
|
||||
<link rel="import" href="../gr-avatar/gr-avatar.html">
|
||||
<link rel="import" href="../gr-limited-text/gr-limited-text.html">
|
||||
<link rel="import" href="../gr-rest-api-interface/gr-rest-api-interface.html">
|
||||
<script src="../../../scripts/util.js"></script>
|
||||
|
||||
<dom-module id="gr-account-label">
|
||||
<template>
|
||||
@ -73,6 +74,5 @@ limitations under the License.
|
||||
</span>
|
||||
<gr-rest-api-interface id="restAPI"></gr-rest-api-interface>
|
||||
</template>
|
||||
<script src="../../../scripts/util.js"></script>
|
||||
<script src="gr-account-label.js"></script>
|
||||
</dom-module>
|
||||
|
@ -24,7 +24,7 @@ limitations under the License.
|
||||
<link rel="import" href="../../core/gr-reporting/gr-reporting.html">
|
||||
|
||||
<dom-module id="gr-button">
|
||||
<template strip-whitespace>
|
||||
<template>
|
||||
<style include="shared-styles">
|
||||
/* general styles for all buttons */
|
||||
:host {
|
||||
|
@ -18,6 +18,7 @@ limitations under the License.
|
||||
<link rel="import" href="/bower_components/polymer/polymer.html">
|
||||
|
||||
<link rel="import" href="../../../styles/shared-styles.html">
|
||||
<script src="../../../scripts/rootElement.js"></script>
|
||||
|
||||
<dom-module id="gr-hovercard">
|
||||
<template>
|
||||
@ -44,6 +45,5 @@ limitations under the License.
|
||||
<slot></slot>
|
||||
</div>
|
||||
</template>
|
||||
<script src="../../../scripts/rootElement.js"></script>
|
||||
<script src="gr-hovercard.js"></script>
|
||||
</dom-module>
|
||||
|
@ -0,0 +1,24 @@
|
||||
<!--
|
||||
@license
|
||||
Copyright (C) 2020 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<link rel="import" href="/bower_components/polymer/polymer.html">
|
||||
<link rel="import" href="../../../behaviors/base-url-behavior/base-url-behavior.html">
|
||||
<link rel="import" href="../../../behaviors/gr-patch-set-behavior/gr-patch-set-behavior.html">
|
||||
|
||||
<dom-module id="gr-js-api-interface">
|
||||
<script src="gr-js-api-interface-element.js"></script>
|
||||
</dom-module>
|
@ -29,26 +29,23 @@ limitations under the License.
|
||||
<link rel="import" href="../../plugins/gr-styles-api/gr-styles-api.html">
|
||||
<link rel="import" href="../../plugins/gr-theme-api/gr-theme-api.html">
|
||||
<link rel="import" href="../gr-rest-api-interface/gr-rest-api-interface.html">
|
||||
|
||||
<dom-module id="gr-js-api-interface">
|
||||
<!--
|
||||
Note: the order matters as files depend on each other.
|
||||
1. gr-api-utils will be used in multiple files below.
|
||||
2. gr-gerrit depends on gr-plugin-loader, gr-public-js-api and
|
||||
also gr-plugin-endpoints
|
||||
3. gr-public-js-api depends on gr-plugin-rest-api
|
||||
-->
|
||||
<script src="gr-api-utils.js"></script>
|
||||
<script src="../gr-event-interface/gr-event-interface.js"></script>
|
||||
<script src="gr-annotation-actions-context.js"></script>
|
||||
<script src="gr-annotation-actions-js-api.js"></script>
|
||||
<script src="gr-change-actions-js-api.js"></script>
|
||||
<script src="gr-change-reply-js-api.js"></script>
|
||||
<script src="gr-js-api-interface.js"></script>
|
||||
<script src="gr-plugin-endpoints.js"></script>
|
||||
<script src="gr-plugin-action-context.js"></script>
|
||||
<script src="gr-plugin-rest-api.js"></script>
|
||||
<script src="gr-public-js-api.js"></script>
|
||||
<script src="gr-plugin-loader.js"></script>
|
||||
<script src="gr-gerrit.js"></script>
|
||||
</dom-module>
|
||||
<!--
|
||||
Note: the order matters as files depend on each other.
|
||||
1. gr-api-utils will be used in multiple files below.
|
||||
2. gr-gerrit depends on gr-plugin-loader, gr-public-js-api and
|
||||
also gr-plugin-endpoints
|
||||
3. gr-public-js-api depends on gr-plugin-rest-api
|
||||
-->
|
||||
<script src="gr-api-utils.js"></script>
|
||||
<script src="../gr-event-interface/gr-event-interface.js"></script>
|
||||
<script src="gr-annotation-actions-context.js"></script>
|
||||
<script src="gr-annotation-actions-js-api.js"></script>
|
||||
<script src="gr-change-actions-js-api.js"></script>
|
||||
<script src="gr-change-reply-js-api.js"></script>
|
||||
<link rel="import" href="./gr-js-api-interface-element.html">
|
||||
<script src="gr-plugin-endpoints.js"></script>
|
||||
<script src="gr-plugin-action-context.js"></script>
|
||||
<script src="gr-plugin-rest-api.js"></script>
|
||||
<script src="gr-public-js-api.js"></script>
|
||||
<script src="gr-plugin-loader.js"></script>
|
||||
<script src="gr-gerrit.js"></script>
|
||||
|
@ -27,7 +27,7 @@ limitations under the License.
|
||||
<link rel="import" href="../gr-rest-api-interface/gr-rest-api-interface.html">
|
||||
|
||||
<dom-module id="gr-label-info">
|
||||
<template strip-whitespace>
|
||||
<template>
|
||||
<style include="gr-voting-styles">
|
||||
/* Workaround for empty style block - see https://github.com/Polymer/tools/issues/408 */
|
||||
</style>
|
||||
|
@ -17,7 +17,7 @@ limitations under the License.
|
||||
<link rel="import" href="/bower_components/polymer/polymer.html">
|
||||
<link rel="import" href="../../../behaviors/gr-tooltip-behavior/gr-tooltip-behavior.html">
|
||||
<dom-module id="gr-label">
|
||||
<template strip-whitespace>
|
||||
<template>
|
||||
<slot></slot>
|
||||
</template>
|
||||
<script src="gr-label.js"></script>
|
||||
|
@ -27,10 +27,11 @@ limitations under the License.
|
||||
<script src="/bower_components/es6-promise/dist/es6-promise.min.js"></script>
|
||||
<script src="/bower_components/fetch/fetch.js"></script>
|
||||
|
||||
<!-- NB: Order is important, because of namespaced classes. -->
|
||||
<script src="gr-rest-apis/gr-rest-api-helper.js"></script>
|
||||
<script src="gr-auth.js"></script>
|
||||
<script src="gr-reviewer-updates-parser.js"></script>
|
||||
|
||||
<dom-module id="gr-rest-api-interface">
|
||||
<!-- NB: Order is important, because of namespaced classes. -->
|
||||
<script src="gr-rest-apis/gr-rest-api-helper.js"></script>
|
||||
<script src="gr-auth.js"></script>
|
||||
<script src="gr-reviewer-updates-parser.js"></script>
|
||||
<script src="gr-rest-api-interface.js"></script>
|
||||
</dom-module>
|
||||
|
Loading…
x
Reference in New Issue
Block a user