Files
gerrit/polygerrit-ui/app/elements/shared/gr-select/gr-select.js
Becky Siegel 8e174ab23a Update gr-select for Polymer 2
Polymer2 does not support type extension. As such, elements that rely on
it are  updated.

Instead of
<select is="gr-select"><select>

This will now be..
<gr-select>
  <select></select>
</gr-select>

This is similar to the implementation of iron-input, except that is more
complex, as it is supporting both type extention and non-type extension.
https://github.com/PolymerElements/iron-input/blob/master/iron-input.html

Bug: Issue 6371
Change-Id: I31091ff24791a9dc073b3325c7b0daa1580b69ef
2017-07-05 14:12:44 -07:00

52 lines
1.3 KiB
JavaScript

// Copyright (C) 2016 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.
(function() {
'use strict';
Polymer({
is: 'gr-select',
properties: {
bindValue: {
type: String,
notify: true,
observer: '_updateValue',
},
},
listeners: {
'change': '_valueChanged',
'dom-change': '_updateValue',
},
get nativeSelect() {
return this.$$('select');
},
_updateValue() {
if (this.bindValue) {
this.nativeSelect.value = this.bindValue;
}
},
_valueChanged() {
this.bindValue = this.nativeSelect.value;
},
ready() {
// If not set via the property, set bind-value to the element value.
if (!this.bindValue) { this.bindValue = this.nativeSelect.value; }
},
});
})();