Remove all usage on POLYMER2

code base is on polymer 2 already

Change-Id: Ic5c9e3181c972fb5baeab3d870276005a7e9fcf0
This commit is contained in:
Tao Zhou
2019-11-04 11:03:23 +01:00
parent f452029096
commit 34486c286e
12 changed files with 5 additions and 25 deletions

View File

@@ -369,7 +369,6 @@
}, },
_getListItems() { _getListItems() {
// Polymer2: querySelectorAll returns NodeList instead of Array.
return Array.from( return Array.from(
Polymer.dom(this.root).querySelectorAll('gr-change-list-item')); Polymer.dom(this.root).querySelectorAll('gr-change-list-item'));
}, },

View File

@@ -332,7 +332,6 @@
}, },
get diffs() { get diffs() {
// Polymer2: querySelectorAll returns NodeList instead of Array.
return Array.from( return Array.from(
Polymer.dom(this.root).querySelectorAll('gr-diff-host')); Polymer.dom(this.root).querySelectorAll('gr-diff-host'));
}, },
@@ -926,7 +925,6 @@
_filesChanged() { _filesChanged() {
if (this._files && this._files.length > 0) { if (this._files && this._files.length > 0) {
Polymer.dom.flush(); Polymer.dom.flush();
// Polymer2: querySelectorAll returns NodeList instead of Array.
const files = Array.from( const files = Array.from(
Polymer.dom(this.root).querySelectorAll('.file-row')); Polymer.dom(this.root).querySelectorAll('.file-row'));
this.$.fileCursor.stops = files; this.$.fileCursor.stops = files;

View File

@@ -422,7 +422,6 @@
* @return {!Array<!HTMLElement>} * @return {!Array<!HTMLElement>}
*/ */
getThreadEls() { getThreadEls() {
// Polymer2: querySelectorAll returns NodeList instead of Array.
return Array.from( return Array.from(
Polymer.dom(this.$.diff).querySelectorAll('.comment-thread')); Polymer.dom(this.$.diff).querySelectorAll('.comment-thread'));
}, },

View File

@@ -73,8 +73,6 @@
}, },
_handleDownOnRangeComment(node) { _handleDownOnRangeComment(node) {
// Keep the original behavior in polymer 1
if (!window.POLYMER2) return false;
if (node && if (node &&
node.nodeName && node.nodeName &&
node.nodeName.toLowerCase() === 'gr-comment-thread') { node.nodeName.toLowerCase() === 'gr-comment-thread') {
@@ -183,13 +181,10 @@
* For Polymer 2, use shadowRoot.getSelection instead. * For Polymer 2, use shadowRoot.getSelection instead.
*/ */
_getSelection() { _getSelection() {
let selection; const diffHost = util.querySelector(document.body, 'gr-diff');
if (window.POLYMER2) { const selection = diffHost &&
const diffHost = util.querySelector(document.body, 'gr-diff'); diffHost.shadowRoot &&
selection = diffHost && diffHost.shadowRoot.getSelection();
diffHost.shadowRoot &&
diffHost.shadowRoot.getSelection();
}
return selection ? selection: window.getSelection(); return selection ? selection: window.getSelection();
}, },

View File

@@ -436,7 +436,6 @@
return []; return [];
} }
// Polymer2: querySelectorAll returns NodeList instead of Array.
return Array.from( return Array.from(
Polymer.dom(this.root).querySelectorAll('.diff-row')); Polymer.dom(this.root).querySelectorAll('.diff-row'));
}, },

View File

@@ -169,10 +169,7 @@
dialog.querySelectorAll('gr-autocomplete') dialog.querySelectorAll('gr-autocomplete')
.forEach(input => { input.text = ''; }); .forEach(input => { input.text = ''; });
// TODO: reveiw binding for input after drop Polymer 1 support dialog.querySelectorAll('iron-input')
// All docs related to Polymer 2 set binding only for iron-input,
// and doesn't add binding to input.
dialog.querySelectorAll(window.POLYMER2 ? 'iron-input' : 'input')
.forEach(input => { input.bindValue = ''; }); .forEach(input => { input.bindValue = ''; });
} }

View File

@@ -74,7 +74,6 @@
}, },
_getEndpointParams() { _getEndpointParams() {
// Polymer2: querySelectorAll returns NodeList instead of Array.
return Array.from( return Array.from(
Polymer.dom(this).querySelectorAll('gr-endpoint-param')); Polymer.dom(this).querySelectorAll('gr-endpoint-param'));
}, },

View File

@@ -41,7 +41,6 @@
* @return {!Array<string>} * @return {!Array<string>}
*/ */
_getDisplayedColumns() { _getDisplayedColumns() {
// Polymer2: querySelectorAll returns NodeList instead of Array.
return Array.from(Polymer.dom(this.root) return Array.from(Polymer.dom(this.root)
.querySelectorAll('.checkboxContainer input:not([name=number])')) .querySelectorAll('.checkboxContainer input:not([name=number])'))
.filter(checkbox => checkbox.checked) .filter(checkbox => checkbox.checked)

View File

@@ -119,7 +119,6 @@
}, },
get accountChips() { get accountChips() {
// Polymer2: querySelectorAll returns NodeList instead of Array.
return Array.from( return Array.from(
Polymer.dom(this.root).querySelectorAll('gr-account-chip')); Polymer.dom(this.root).querySelectorAll('gr-account-chip'));
}, },

View File

@@ -161,7 +161,6 @@
if (this.suggestions.length > 0) { if (this.suggestions.length > 0) {
if (!this.isHidden) { if (!this.isHidden) {
Polymer.dom.flush(); Polymer.dom.flush();
// Polymer2: querySelectorAll returns NodeList instead of Array.
this._suggestionEls = Array.from( this._suggestionEls = Array.from(
this.$.suggestions.querySelectorAll('li')); this.$.suggestions.querySelectorAll('li'));
this._resetCursorIndex(); this._resetCursorIndex();

View File

@@ -20,7 +20,6 @@ limitations under the License.
href="/bower_components/polymer-resin/standalone/polymer-resin.html" /> href="/bower_components/polymer-resin/standalone/polymer-resin.html" />
<link rel="import" href="../behaviors/safe-types-behavior/safe-types-behavior.html"> <link rel="import" href="../behaviors/safe-types-behavior/safe-types-behavior.html">
<script> <script>
window.POLYMER2 = true;
security.polymer_resin.install({ security.polymer_resin.install({
allowedIdentifierPrefixes: [''], allowedIdentifierPrefixes: [''],
reportHandler(isViolation, fmt, ...args) { reportHandler(isViolation, fmt, ...args) {

View File

@@ -15,8 +15,6 @@
* limitations under the License. * limitations under the License.
*/ */
window.POLYMER2 = true;
/** /**
* Helps looking up the proper iron-input element during the Polymer 2 * Helps looking up the proper iron-input element during the Polymer 2
* transition. Polymer 2 uses the <iron-input> element, while Polymer 1 uses * transition. Polymer 2 uses the <iron-input> element, while Polymer 1 uses