Port Android relocation packer to chromium build
[chromium-blink-merge.git] / third_party / polymer / components-chromium / core-input / core-input-extracted.js
blob651611ebeeec8bb103f1e22778a5e9b774e688de
3 Polymer('core-input', {
5 publish: {
7 /**
8 * The "committed" value of the input, ie. the input value when the user
9 * hits the "enter" key or blurs the input after changing the value. You
10 * can bind to this value instead of listening for the "change" event.
11 * Setting this property has no effect on the input value.
13 * @attribute committedValue
14 * @type string
15 * @default ''
17 committedValue: '',
19 /**
20 * Set to true to prevent invalid input from being entered.
22 * @attribute preventInvalidInput
23 * @type boolean
24 * @default false
26 preventInvalidInput: false
30 previousValidInput: '',
32 eventDelegates: {
33 input: 'inputAction',
34 change: 'changeAction'
37 ready: function() {
38 /* set ARIA attributes */
39 this.disabledHandler();
40 this.placeholderHandler();
43 attributeChanged: function(attr, old) {
44 if (this[attr + 'Handler']) {
45 this[attr + 'Handler'](old);
49 disabledHandler: function() {
50 if (this.disabled) {
51 this.setAttribute('aria-disabled', '');
52 } else {
53 this.removeAttribute('aria-disabled');
57 placeholderHandler: function() {
58 if (this.placeholder) {
59 this.setAttribute('aria-label', this.placeholder);
60 } else {
61 this.removeAttribute('aria-label');
65 /**
66 * Commits the `value` to `committedValue`
68 * @method commit
70 commit: function() {
71 this.committedValue = this.value;
74 changeAction: function() {
75 this.commit();
78 inputAction: function(e) {
79 if (this.preventInvalidInput) {
80 if (!e.target.validity.valid) {
81 e.target.value = this.previousValidInput;
82 } else {
83 this.previousValidInput = e.target.value;
88 });