| OLD | NEW |
| 1 /** | 1 /** |
| 2 * Use `Polymer.IronCheckedElementBehavior` to implement a custom element | 2 * Use `Polymer.IronCheckedElementBehavior` to implement a custom element |
| 3 * that has a `checked` property, which can be used for validation if the | 3 * that has a `checked` property, which can be used for validation if the |
| 4 * element is also `required`. Element instances implementing this behavior | 4 * element is also `required`. Element instances implementing this behavior |
| 5 * will also be registered for use in an `iron-form` element. | 5 * will also be registered for use in an `iron-form` element. |
| 6 * | 6 * |
| 7 * @demo demo/index.html | 7 * @demo demo/index.html |
| 8 * @polymerBehavior Polymer.IronCheckedElementBehavior | 8 * @polymerBehavior Polymer.IronCheckedElementBehavior |
| 9 */ | 9 */ |
| 10 Polymer.IronCheckedElementBehaviorImpl = { | 10 Polymer.IronCheckedElementBehaviorImpl = { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 created: function() { | 52 created: function() { |
| 53 // Used by `iron-form` to handle the case that an element with this behavi
or | 53 // Used by `iron-form` to handle the case that an element with this behavi
or |
| 54 // doesn't have a role of 'checkbox' or 'radio', but should still only be | 54 // doesn't have a role of 'checkbox' or 'radio', but should still only be |
| 55 // included when the form is serialized if `this.checked === true`. | 55 // included when the form is serialized if `this.checked === true`. |
| 56 this._hasIronCheckedElementBehavior = true; | 56 this._hasIronCheckedElementBehavior = true; |
| 57 }, | 57 }, |
| 58 | 58 |
| 59 /** | 59 /** |
| 60 * Returns false if the element is required and not checked, and true otherw
ise. | 60 * Returns false if the element is required and not checked, and true otherw
ise. |
| 61 * @param {*=} _value Ignored. | 61 * @param {*=} _value Ignored. |
| 62 * @return {boolean} true if `required` is false, or if `required` and `chec
ked` are both true. | 62 * @return {boolean} true if `required` is false or if `checked` is true. |
| 63 */ | 63 */ |
| 64 _getValidity: function(_value) { | 64 _getValidity: function(_value) { |
| 65 return this.disabled || !this.required || (this.required && this.checked); | 65 return this.disabled || !this.required || this.checked; |
| 66 }, | 66 }, |
| 67 | 67 |
| 68 /** | 68 /** |
| 69 * Update the aria-required label when `required` is changed. | 69 * Update the aria-required label when `required` is changed. |
| 70 */ | 70 */ |
| 71 _requiredChanged: function() { | 71 _requiredChanged: function() { |
| 72 if (this.required) { | 72 if (this.required) { |
| 73 this.setAttribute('aria-required', 'true'); | 73 this.setAttribute('aria-required', 'true'); |
| 74 } else { | 74 } else { |
| 75 this.removeAttribute('aria-required'); | 75 this.removeAttribute('aria-required'); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 93 } | 93 } |
| 94 } | 94 } |
| 95 }; | 95 }; |
| 96 | 96 |
| 97 /** @polymerBehavior Polymer.IronCheckedElementBehavior */ | 97 /** @polymerBehavior Polymer.IronCheckedElementBehavior */ |
| 98 Polymer.IronCheckedElementBehavior = [ | 98 Polymer.IronCheckedElementBehavior = [ |
| 99 Polymer.IronFormElementBehavior, | 99 Polymer.IronFormElementBehavior, |
| 100 Polymer.IronValidatableBehavior, | 100 Polymer.IronValidatableBehavior, |
| 101 Polymer.IronCheckedElementBehaviorImpl | 101 Polymer.IronCheckedElementBehaviorImpl |
| 102 ]; | 102 ]; |
| OLD | NEW |