Commit d3fd3aab authored by dpapad's avatar dpapad Committed by Commit Bot

Polymer: Remove iron-input from third_party/polymer.

No longer used anywhere. Also removing IronValidatableBehavior which
was only used by iron-input, and is now also unused.

Fixed: 899982
Change-Id: I12cedab34ee8ab62e0b40ef4e69d67970d123f2c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2238997Reviewed-by: default avatarRebekah Potter <rbpotter@chromium.org>
Commit-Queue: Rebekah Potter <rbpotter@chromium.org>
Auto-Submit: dpapad <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#777255}
parent a450130e
......@@ -14,7 +14,6 @@
"iron-flex-layout": "PolymerElements/iron-flex-layout#2.0.3",
"iron-icon": "PolymerElements/iron-icon#2.0.1",
"iron-iconset-svg": "PolymerElements/iron-iconset-svg#2.1.1",
"iron-input": "PolymerElements/iron-input#2.1.3",
"iron-list": "PolymerElements/iron-list#2.0.20",
"iron-location": "PolymerElements/iron-location#2.0.3",
"iron-media-query": "PolymerElements/iron-media-query#2.0.0",
......@@ -27,7 +26,6 @@
"iron-scroll-threshold": "PolymerElements/iron-scroll-threshold#2.0.0",
"iron-selector": "PolymerElements/iron-selector#2.0.1",
"iron-test-helpers": "PolymerElements/iron-test-helpers#2.0.0",
"iron-validatable-behavior": "PolymerElements/iron-validatable-behavior#2.1.0",
"neon-animation": "PolymerElements/neon-animation#2.1.0",
"paper-behaviors": "PolymerElements/paper-behaviors#2.1.0",
"paper-progress": "PolymerElements/paper-progress#2.0.1",
......
# Copyright 2020 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
#
# NOTE: Created with generate_gn.py, please do not edit.
import("//third_party/closure_compiler/compile_js.gni")
js_library("iron-input-extracted") {
deps = [
"../iron-a11y-announcer:iron-a11y-announcer-extracted",
"../iron-validatable-behavior:iron-validatable-behavior-extracted",
]
}
{
"name": "iron-input",
"version": "2.1.3",
"description": "An input element with data binding",
"authors": [
"The Polymer Authors"
],
"keywords": [
"web-components",
"polymer",
"input"
],
"main": "iron-input.html",
"private": true,
"repository": {
"type": "git",
"url": "git://github.com/PolymerElements/iron-input.git"
},
"license": "http://polymer.github.io/LICENSE.txt",
"homepage": "https://github.com/PolymerElements/iron-input",
"ignore": [],
"dependencies": {
"iron-a11y-announcer": "PolymerElements/iron-a11y-announcer#1 - 2",
"iron-validatable-behavior": "PolymerElements/iron-validatable-behavior#1 - 2",
"polymer": "Polymer/polymer#1.9 - 2"
},
"devDependencies": {
"iron-component-page": "polymerelements/iron-component-page#1 - 2",
"iron-demo-helpers": "polymerelements/iron-demo-helpers#1 - 2",
"iron-validator-behavior": "PolymerElements/iron-validator-behavior#1 - 2",
"paper-styles": "polymerelements/paper-styles#1 - 2",
"test-fixture": "PolymerElements/test-fixture#^3.0.0-rc.1",
"web-component-tester": "^6.0.0",
"webcomponentsjs": "webcomponents/webcomponentsjs#^1.0.0"
},
"variants": {
"1.x": {
"dependencies": {
"iron-a11y-announcer": "PolymerElements/iron-a11y-announcer#^1.0.0",
"iron-validatable-behavior": "PolymerElements/iron-validatable-behavior#^1.0.0",
"polymer": "Polymer/polymer#^1.9"
},
"devDependencies": {
"iron-component-page": "polymerelements/iron-component-page#^1.0.0",
"iron-demo-helpers": "polymerelements/iron-demo-helpers#^1.0.0",
"iron-validator-behavior": "PolymerElements/iron-validator-behavior#^1.0.0",
"paper-styles": "polymerelements/paper-styles#^1.0.0",
"test-fixture": "PolymerElements/test-fixture#^1.0.0",
"webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0",
"web-component-tester": "Polymer/web-component-tester#^4.0.0"
},
"resolutions": {
"webcomponentsjs": "^0.7"
}
}
},
"resolutions": {
"webcomponentsjs": "^1.0.0"
}
}
Polymer({
is: 'iron-input',
behaviors: [Polymer.IronValidatableBehavior],
/**
* Fired whenever `validate()` is called.
*
* @event iron-input-validate
*/
properties: {
/**
* Use this property instead of `value` for two-way data binding, or to
* set a default value for the input. **Do not** use the distributed
* input's `value` property to set a default value.
*/
bindValue: {type: String, value: ''},
/**
* Computed property that echoes `bindValue` (mostly used for Polymer 1.0
* backcompatibility, if you were one-way binding to the Polymer 1.0
* `input is="iron-input"` value attribute).
*/
value: {type: String, computed: '_computeValue(bindValue)'},
/**
* Regex-like list of characters allowed as input; all characters not in the
* list will be rejected. The recommended format should be a list of allowed
* characters, for example, `[a-zA-Z0-9.+-!;:]`.
*
* This pattern represents the allowed characters for the field; as the user
* inputs text, each individual character will be checked against the
* pattern (rather than checking the entire value as a whole). If a
* character is not a match, it will be rejected.
*
* Pasted input will have each character checked individually; if any
* character doesn't match `allowedPattern`, the entire pasted string will
* be rejected.
*
* Note: if you were using `iron-input` in 1.0, you were also required to
* set `prevent-invalid-input`. This is no longer needed as of Polymer 2.0,
* and will be set automatically for you if an `allowedPattern` is provided.
*
*/
allowedPattern: {type: String},
/**
* Set to true to auto-validate the input value as you type.
*/
autoValidate: {type: Boolean, value: false},
/**
* The native input element.
*/
_inputElement: Object,
},
observers: ['_bindValueChanged(bindValue, _inputElement)'],
listeners: {'input': '_onInput', 'keypress': '_onKeypress'},
created: function() {
Polymer.IronA11yAnnouncer.requestAvailability();
this._previousValidInput = '';
this._patternAlreadyChecked = false;
},
attached: function() {
// If the input is added at a later time, update the internal reference.
this._observer = Polymer.dom(this).observeNodes(function(info) {
this._initSlottedInput();
}.bind(this));
},
detached: function() {
if (this._observer) {
Polymer.dom(this).unobserveNodes(this._observer);
this._observer = null;
}
},
/**
* Returns the distributed input element.
*/
get inputElement() {
return this._inputElement;
},
_initSlottedInput: function() {
this._inputElement = this.getEffectiveChildren()[0];
if (this.inputElement && this.inputElement.value) {
this.bindValue = this.inputElement.value;
}
this.fire('iron-input-ready');
},
get _patternRegExp() {
var pattern;
if (this.allowedPattern) {
pattern = new RegExp(this.allowedPattern);
} else {
switch (this.inputElement.type) {
case 'number':
pattern = /[0-9.,e-]/;
break;
}
}
return pattern;
},
/**
* @suppress {checkTypes}
*/
_bindValueChanged: function(bindValue, inputElement) {
// The observer could have run before attached() when we have actually
// initialized this property.
if (!inputElement) {
return;
}
if (bindValue === undefined) {
inputElement.value = null;
} else if (bindValue !== inputElement.value) {
this.inputElement.value = bindValue;
}
if (this.autoValidate) {
this.validate();
}
// manually notify because we don't want to notify until after setting value
this.fire('bind-value-changed', {value: bindValue});
},
_onInput: function() {
// Need to validate each of the characters pasted if they haven't
// been validated inside `_onKeypress` already.
if (this.allowedPattern && !this._patternAlreadyChecked) {
var valid = this._checkPatternValidity();
if (!valid) {
this._announceInvalidCharacter(
'Invalid string of characters not entered.');
this.inputElement.value = this._previousValidInput;
}
}
this.bindValue = this._previousValidInput = this.inputElement.value;
this._patternAlreadyChecked = false;
},
_isPrintable: function(event) {
// What a control/printable character is varies wildly based on the browser.
// - most control characters (arrows, backspace) do not send a `keypress`
// event
// in Chrome, but the *do* on Firefox
// - in Firefox, when they do send a `keypress` event, control chars have
// a charCode = 0, keyCode = xx (for ex. 40 for down arrow)
// - printable characters always send a keypress event.
// - in Firefox, printable chars always have a keyCode = 0. In Chrome, the
// keyCode
// always matches the charCode.
// None of this makes any sense.
// For these keys, ASCII code == browser keycode.
var anyNonPrintable = (event.keyCode == 8) || // backspace
(event.keyCode == 9) || // tab
(event.keyCode == 13) || // enter
(event.keyCode == 27); // escape
// For these keys, make sure it's a browser keycode and not an ASCII code.
var mozNonPrintable = (event.keyCode == 19) || // pause
(event.keyCode == 20) || // caps lock
(event.keyCode == 45) || // insert
(event.keyCode == 46) || // delete
(event.keyCode == 144) || // num lock
(event.keyCode == 145) || // scroll lock
(event.keyCode > 32 &&
event.keyCode < 41) || // page up/down, end, home, arrows
(event.keyCode > 111 && event.keyCode < 124); // fn keys
return !anyNonPrintable && !(event.charCode == 0 && mozNonPrintable);
},
_onKeypress: function(event) {
if (!this.allowedPattern && this.inputElement.type !== 'number') {
return;
}
var regexp = this._patternRegExp;
if (!regexp) {
return;
}
// Handle special keys and backspace
if (event.metaKey || event.ctrlKey || event.altKey) {
return;
}
// Check the pattern either here or in `_onInput`, but not in both.
this._patternAlreadyChecked = true;
var thisChar = String.fromCharCode(event.charCode);
if (this._isPrintable(event) && !regexp.test(thisChar)) {
event.preventDefault();
this._announceInvalidCharacter(
'Invalid character ' + thisChar + ' not entered.');
}
},
_checkPatternValidity: function() {
var regexp = this._patternRegExp;
if (!regexp) {
return true;
}
for (var i = 0; i < this.inputElement.value.length; i++) {
if (!regexp.test(this.inputElement.value[i])) {
return false;
}
}
return true;
},
/**
* Returns true if `value` is valid. The validator provided in `validator`
* will be used first, then any constraints.
* @return {boolean} True if the value is valid.
*/
validate: function() {
if (!this.inputElement) {
this.invalid = false;
return true;
}
// Use the nested input's native validity.
var valid = this.inputElement.checkValidity();
// Only do extra checking if the browser thought this was valid.
if (valid) {
// Empty, required input is invalid
if (this.required && this.bindValue === '') {
valid = false;
} else if (this.hasValidator()) {
valid =
Polymer.IronValidatableBehavior.validate.call(this, this.bindValue);
}
}
this.invalid = !valid;
this.fire('iron-input-validate');
return valid;
},
_announceInvalidCharacter: function(message) {
this.fire('iron-announce', {text: message});
},
_computeValue: function(bindValue) {
return bindValue;
}
});
\ No newline at end of file
<!--
@license
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
--><html><head><link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../iron-a11y-announcer/iron-a11y-announcer.html">
<link rel="import" href="../iron-validatable-behavior/iron-validatable-behavior.html">
<!--
`<iron-input>` is a wrapper to a native `<input>` element, that adds two-way binding
and prevention of invalid input. To use it, you must distribute a native `<input>`
yourself. You can continue to use the native `input` as you would normally:
<iron-input>
<input>
</iron-input>
<iron-input>
<input type="email" disabled>
</iron-input>
### Two-way binding
By default you can only get notified of changes to a native `<input>`'s `value`
due to user input:
<input value="{{myValue::input}}">
This means that if you imperatively set the value (i.e. `someNativeInput.value = 'foo'`),
no events will be fired and this change cannot be observed.
`iron-input` adds the `bind-value` property that mirrors the native `input`'s '`value` property; this
property can be used for two-way data binding.
`bind-value` will notify if it is changed either by user input or by script.
<iron-input bind-value="{{myValue}}">
<input>
</iron-input>
Note: this means that if you want to imperatively set the native `input`'s, you _must_
set `bind-value` instead, so that the wrapper `iron-input` can be notified.
### Validation
`iron-input` uses the native `input`'s validation. For simplicity, `iron-input`
has a `validate()` method (which internally just checks the distributed `input`'s
validity), which sets an `invalid` attribute that can also be used for styling.
To validate automatically as you type, you can use the `auto-validate` attribute.
`iron-input` also fires an `iron-input-validate` event after `validate()` is
called. You can use it to implement a custom validator:
var CatsOnlyValidator = {
validate: function(ironInput) {
var valid = !ironInput.bindValue || ironInput.bindValue === 'cat';
ironInput.invalid = !valid;
return valid;
}
}
ironInput.addEventListener('iron-input-validate', function() {
CatsOnly.validate(input2);
});
You can also use an element implementing an [`IronValidatorBehavior`](/element/PolymerElements/iron-validatable-behavior).
This example can also be found in the demo for this element:
<iron-input validator="cats-only">
<input>
</iron-input>
### Preventing invalid input
It may be desirable to only allow users to enter certain characters. You can use the
`allowed-pattern` attribute to accomplish this. This feature
is separate from validation, and `allowed-pattern` does not affect how the input is validated.
// Only allow typing digits, but a valid input has exactly 5 digits.
<iron-input allowed-pattern="[0-9]">
<input pattern="\d{5}">
</iron-input>
@hero hero.svg
@demo demo/index.html
-->
</head><body><dom-module id="iron-input">
<template>
<style>
:host {
display: inline-block;
}
</style>
<slot id="content"></slot>
</template>
</dom-module>
<script src="iron-input-extracted.js"></script></body></html>
\ No newline at end of file
# Copyright 2020 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
#
# NOTE: Created with generate_gn.py, please do not edit.
import("//third_party/closure_compiler/compile_js.gni")
js_library("iron-validatable-behavior-extracted") {
deps = [ "../iron-meta:iron-meta-extracted" ]
}
{
"name": "iron-validatable-behavior",
"version": "2.0.0",
"description": "Provides a behavior for an element that validates user input",
"authors": "The Polymer Authors",
"keywords": [
"web-components",
"polymer",
"iron",
"behavior"
],
"main": "iron-validatable-behavior.html",
"private": true,
"repository": {
"type": "git",
"url": "git://github.com/PolymerElements/iron-validatable-behavior.git"
},
"license": "http://polymer.github.io/LICENSE.txt",
"homepage": "https://github.com/PolymerElements/iron-validatable-behavior",
"ignore": [],
"dependencies": {
"iron-meta": "PolymerElements/iron-meta#1 - 2",
"polymer": "Polymer/polymer#1.9 - 2"
},
"devDependencies": {
"iron-component-page": "PolymerElements/iron-component-page#1 - 2",
"iron-demo-helpers": "PolymerElements/iron-demo-helpers#1 - 2",
"iron-validator-behavior": "PolymerElements/iron-validator-behavior#1 - 2",
"paper-styles": "PolymerElements/paper-styles#1 - 2",
"test-fixture": "PolymerElements/test-fixture#^3.0.0-rc.1",
"web-component-tester": "^6.0.0",
"webcomponentsjs": "webcomponents/webcomponentsjs#^1.0.0"
},
"variants": {
"1.x": {
"dependencies": {
"iron-meta": "PolymerElements/iron-meta#^1.0.0",
"polymer": "Polymer/polymer#^1.9"
},
"devDependencies": {
"iron-component-page": "PolymerElements/iron-component-page#^1.0.0",
"iron-demo-helpers": "PolymerElements/iron-demo-helpers#^1.0.0",
"iron-validator-behavior": "PolymerElements/iron-validator-behavior#^1.0.0",
"paper-styles": "PolymerElements/paper-styles#^1.0.4",
"test-fixture": "PolymerElements/test-fixture#^1.0.0",
"webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0",
"web-component-tester": "^4.0.0"
},
"resolutions": {
"webcomponentsjs": "^0.7"
}
}
},
"resolutions": {
"webcomponentsjs": "^1.0.0"
}
}
/**
* Singleton IronMeta instance.
*/
Polymer.IronValidatableBehaviorMeta = null;
/**
* `Use Polymer.IronValidatableBehavior` to implement an element that validates user input.
* Use the related `Polymer.IronValidatorBehavior` to add custom validation logic to an iron-input.
*
* By default, an `<iron-form>` element validates its fields when the user presses the submit button.
* To validate a form imperatively, call the form's `validate()` method, which in turn will
* call `validate()` on all its children. By using `Polymer.IronValidatableBehavior`, your
* custom element will get a public `validate()`, which
* will return the validity of the element, and a corresponding `invalid` attribute,
* which can be used for styling.
*
* To implement the custom validation logic of your element, you must override
* the protected `_getValidity()` method of this behaviour, rather than `validate()`.
* See [this](https://github.com/PolymerElements/iron-form/blob/master/demo/simple-element.html)
* for an example.
*
* ### Accessibility
*
* Changing the `invalid` property, either manually or by calling `validate()` will update the
* `aria-invalid` attribute.
*
* @demo demo/index.html
* @polymerBehavior
*/
Polymer.IronValidatableBehavior = {
properties: {
/**
* Name of the validator to use.
*/
validator: {
type: String
},
/**
* True if the last call to `validate` is invalid.
*/
invalid: {
notify: true,
reflectToAttribute: true,
type: Boolean,
value: false,
observer: '_invalidChanged'
},
},
registered: function() {
Polymer.IronValidatableBehaviorMeta = new Polymer.IronMeta({type: 'validator'});
},
_invalidChanged: function() {
if (this.invalid) {
this.setAttribute('aria-invalid', 'true');
} else {
this.removeAttribute('aria-invalid');
}
},
/* Recompute this every time it's needed, because we don't know if the
* underlying IronValidatableBehaviorMeta has changed. */
get _validator() {
return Polymer.IronValidatableBehaviorMeta &&
Polymer.IronValidatableBehaviorMeta.byKey(this.validator);
},
/**
* @return {boolean} True if the validator `validator` exists.
*/
hasValidator: function() {
return this._validator != null;
},
/**
* Returns true if the `value` is valid, and updates `invalid`. If you want
* your element to have custom validation logic, do not override this method;
* override `_getValidity(value)` instead.
* @param {Object} value Deprecated: The value to be validated. By default,
* it is passed to the validator's `validate()` function, if a validator is set.
* If this argument is not specified, then the element's `value` property
* is used, if it exists.
* @return {boolean} True if `value` is valid.
*/
validate: function(value) {
// If this is an element that also has a value property, and there was
// no explicit value argument passed, use the element's property instead.
if (value === undefined && this.value !== undefined)
this.invalid = !this._getValidity(this.value);
else
this.invalid = !this._getValidity(value);
return !this.invalid;
},
/**
* Returns true if `value` is valid. By default, it is passed
* to the validator's `validate()` function, if a validator is set. You
* should override this method if you want to implement custom validity
* logic for your element.
*
* @param {Object} value The value to be validated.
* @return {boolean} True if `value` is valid.
*/
_getValidity: function(value) {
if (this.hasValidator()) {
return this._validator.validate(value);
}
return true;
}
};
\ No newline at end of file
<!--
@license
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
--><html><head><link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../iron-meta/iron-meta.html">
</head><body><script src="iron-validatable-behavior-extracted.js"></script></body></html>
\ No newline at end of file
......@@ -70,12 +70,6 @@ Tree: v2.1.1
Revision: 0f36a7d380e0edfd81344e6cdbc89519355df8bd
Tree link: https://github.com/PolymerElements/iron-iconset-svg/tree/v2.1.1
Name: iron-input
Repository: https://github.com/PolymerElements/iron-input.git
Tree: v2.1.3
Revision: 72a4a9e898a4b825602eacd78944e8e25ee41f5c
Tree link: https://github.com/PolymerElements/iron-input/tree/v2.1.3
Name: iron-list
Repository: https://github.com/PolymerElements/iron-list.git
Tree: v2.0.20
......@@ -148,12 +142,6 @@ Tree: v2.0.0
Revision: b972ff1579d882f3196713f8a72a8bf77aeba07c
Tree link: https://github.com/PolymerElements/iron-test-helpers/tree/v2.0.0
Name: iron-validatable-behavior
Repository: https://github.com/PolymerElements/iron-validatable-behavior.git
Tree: v2.1.0
Revision: 4b6c1c53e44a3bbb31fcfd14ede2234645518c96
Tree link: https://github.com/PolymerElements/iron-validatable-behavior/tree/v2.1.0
Name: neon-animation
Repository: https://github.com/PolymerElements/neon-animation.git
Tree: v2.1.0
......
......@@ -38,6 +38,9 @@ iron-checked-element-behavior/*
# iron-form-element-behavior
iron-form-element-behavior/*
# iron-validatable-behavior
iron-validatable-behavior/*
# iron-test-helpers
iron-test-helpers/iron-test-helpers.html
iron-test-helpers/test-helpers.html
......
# Copyright 2020 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
#
# NOTE: Created with generate_gn_v3.py, please do not edit.
import("//third_party/closure_compiler/compile_js.gni")
js_library("iron-input") {
deps = [
"../iron-a11y-announcer:iron-a11y-announcer",
"../iron-validatable-behavior:iron-validatable-behavior",
"../polymer:polymer_bundled",
]
}
# Copyright 2020 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
#
# NOTE: Created with generate_gn_v3.py, please do not edit.
import("//third_party/closure_compiler/compile_js.gni")
js_library("iron-validatable-behavior") {
deps = [
"../iron-meta:iron-meta",
"../polymer:polymer_bundled",
]
}
/**
@license
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at
http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
part of the polymer project is also subject to an additional IP rights grant
found at http://polymer.github.io/PATENTS.txt
*/
import '../polymer/polymer_bundled.min.js';
import {IronMeta} from '../iron-meta/iron-meta.js';
/**
* Singleton IronMeta instance.
*/
export let IronValidatableBehaviorMeta = null;
/**
* `Use IronValidatableBehavior` to implement an element that validates
* user input. Use the related `IronValidatorBehavior` to add custom
* validation logic to an iron-input.
*
* By default, an `<iron-form>` element validates its fields when the user
* presses the submit button. To validate a form imperatively, call the form's
* `validate()` method, which in turn will call `validate()` on all its
* children. By using `IronValidatableBehavior`, your custom element
* will get a public `validate()`, which will return the validity of the
* element, and a corresponding `invalid` attribute, which can be used for
* styling.
*
* To implement the custom validation logic of your element, you must override
* the protected `_getValidity()` method of this behaviour, rather than
* `validate()`. See
* [this](https://github.com/PolymerElements/iron-form/blob/master/demo/simple-element.html)
* for an example.
*
* ### Accessibility
*
* Changing the `invalid` property, either manually or by calling `validate()`
* will update the `aria-invalid` attribute.
*
* @demo demo/index.html
* @polymerBehavior
*/
export const IronValidatableBehavior = {
properties: {
/**
* Name of the validator to use.
*/
validator: {type: String},
/**
* True if the last call to `validate` is invalid.
*/
invalid: {
notify: true,
reflectToAttribute: true,
type: Boolean,
value: false,
observer: '_invalidChanged'
},
},
registered: function() {
IronValidatableBehaviorMeta = new IronMeta({type: 'validator'});
},
_invalidChanged: function() {
if (this.invalid) {
this.setAttribute('aria-invalid', 'true');
} else {
this.removeAttribute('aria-invalid');
}
},
/* Recompute this every time it's needed, because we don't know if the
* underlying IronValidatableBehaviorMeta has changed. */
get _validator() {
return IronValidatableBehaviorMeta &&
IronValidatableBehaviorMeta.byKey(this.validator);
},
/**
* @return {boolean} True if the validator `validator` exists.
*/
hasValidator: function() {
return this._validator != null;
},
/**
* Returns true if the `value` is valid, and updates `invalid`. If you want
* your element to have custom validation logic, do not override this method;
* override `_getValidity(value)` instead.
* @param {Object} value Deprecated: The value to be validated. By default,
* it is passed to the validator's `validate()` function, if a validator is
set.
* If this argument is not specified, then the element's `value` property
* is used, if it exists.
* @return {boolean} True if `value` is valid.
*/
validate: function(value) {
// If this is an element that also has a value property, and there was
// no explicit value argument passed, use the element's property instead.
if (value === undefined && this.value !== undefined)
this.invalid = !this._getValidity(this.value);
else
this.invalid = !this._getValidity(value);
return !this.invalid;
},
/**
* Returns true if `value` is valid. By default, it is passed
* to the validator's `validate()` function, if a validator is set. You
* should override this method if you want to implement custom validity
* logic for your element.
*
* @param {Object} value The value to be validated.
* @return {boolean} True if `value` is valid.
*/
_getValidity: function(value) {
if (this.hasValidator()) {
return this._validator.validate(value);
}
return true;
}
};
......@@ -116,16 +116,6 @@
"@polymer/polymer": "^3.0.0"
}
},
"@polymer/iron-input": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/@polymer/iron-input/-/iron-input-3.0.1.tgz",
"integrity": "sha512-WLx13kEcbH9GKbj9+pWR6pbJkA5kxn3796ynx6eQd2rueMyUfVTR3GzOvadBKsciUuIuzrxpBWZ2+3UcueVUQQ==",
"requires": {
"@polymer/iron-a11y-announcer": "^3.0.0-pre.26",
"@polymer/iron-validatable-behavior": "^3.0.0-pre.26",
"@polymer/polymer": "^3.0.0"
}
},
"@polymer/iron-list": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/@polymer/iron-list/-/iron-list-3.1.0.tgz",
......
......@@ -14,7 +14,6 @@
"@polymer/iron-flex-layout": "3.0.1",
"@polymer/iron-icon": "3.0.1",
"@polymer/iron-iconset-svg": "3.0.1",
"@polymer/iron-input": "3.0.1",
"@polymer/iron-list": "3.1.0",
"@polymer/iron-location": "3.0.1",
"@polymer/iron-media-query": "3.0.1",
......@@ -27,7 +26,6 @@
"@polymer/iron-scroll-threshold": "3.0.1",
"@polymer/iron-selector": "3.0.1",
"@polymer/iron-test-helpers": "3.0.1",
"@polymer/iron-validatable-behavior": "3.0.1",
"@polymer/neon-animation": "3.0.1",
"@polymer/paper-behaviors": "3.0.1",
"@polymer/paper-progress": "3.0.1",
......
......@@ -37,6 +37,9 @@ iron-checked-element-behavior/*
# iron-form-element-behavior
iron-form-element-behavior/*
# iron-validatable-behavior
iron-validatable-behavior/*
# iron-test-helpers
iron-test-helpers/iron-test-helpers.js
iron-test-helpers/test-helpers.js
......
......@@ -106,14 +106,6 @@
<structure name="IDR_POLYMER_1_0_IRON_ICONSET_SVG_IRON_ICONSET_SVG_HTML"
file="../../../third_party/polymer/v1_0/components-chromium/iron-iconset-svg/iron-iconset-svg.html"
type="chrome_html" />
<if expr="chromeos">
<structure name="IDR_POLYMER_1_0_IRON_INPUT_IRON_INPUT_EXTRACTED_JS"
file="../../../third_party/polymer/v1_0/components-chromium/iron-input/iron-input-extracted.js"
type="chrome_html" />
<structure name="IDR_POLYMER_1_0_IRON_INPUT_IRON_INPUT_HTML"
file="../../../third_party/polymer/v1_0/components-chromium/iron-input/iron-input.html"
type="chrome_html" />
</if>
<structure name="IDR_POLYMER_1_0_IRON_LIST_IRON_LIST_EXTRACTED_JS"
file="../../../third_party/polymer/v1_0/components-chromium/iron-list/iron-list-extracted.js"
type="chrome_html" />
......@@ -231,12 +223,6 @@
file="../../../third_party/polymer/v1_0/components-chromium/iron-selector/iron-selector.html"
type="chrome_html" />
<if expr="chromeos">
<structure name="IDR_POLYMER_1_0_IRON_VALIDATABLE_BEHAVIOR_IRON_VALIDATABLE_BEHAVIOR_EXTRACTED_JS"
file="../../../third_party/polymer/v1_0/components-chromium/iron-validatable-behavior/iron-validatable-behavior-extracted.js"
type="chrome_html" />
<structure name="IDR_POLYMER_1_0_IRON_VALIDATABLE_BEHAVIOR_IRON_VALIDATABLE_BEHAVIOR_HTML"
file="../../../third_party/polymer/v1_0/components-chromium/iron-validatable-behavior/iron-validatable-behavior.html"
type="chrome_html" />
<structure name="IDR_POLYMER_1_0_NEON_ANIMATION_ANIMATIONS_FADE_IN_ANIMATION_EXTRACTED_JS"
file="../../../third_party/polymer/v1_0/components-chromium/neon-animation/animations/fade-in-animation-extracted.js"
type="chrome_html" />
......
......@@ -68,11 +68,6 @@
<structure name="IDR_POLYMER_3_0_IRON_ICON_IRON_ICON_JS"
file="../../../third_party/polymer/v3_0/components-chromium/iron-icon/iron-icon.js"
type="chrome_html" />
<if expr="chromeos">
<structure name="IDR_POLYMER_3_0_IRON_INPUT_IRON_INPUT_JS"
file="../../../third_party/polymer/v3_0/components-chromium/iron-input/iron-input.js"
type="chrome_html" />
</if>
<structure name="IDR_POLYMER_3_0_IRON_LIST_IRON_LIST_JS"
file="../../../third_party/polymer/v3_0/components-chromium/iron-list/iron-list.js"
type="chrome_html" />
......@@ -136,9 +131,6 @@
file="../../../third_party/polymer/v3_0/components-chromium/iron-test-helpers/mock-interactions.js"
type="chrome_html" />
<if expr="chromeos">
<structure name="IDR_POLYMER_3_0_IRON_VALIDATABLE_BEHAVIOR_IRON_VALIDATABLE_BEHAVIOR_JS"
file="../../../third_party/polymer/v3_0/components-chromium/iron-validatable-behavior/iron-validatable-behavior.js"
type="chrome_html" />
<structure name="IDR_POLYMER_3_0_NEON_ANIMATION_ANIMATIONS_FADE_IN_ANIMATION_JS"
file="../../../third_party/polymer/v3_0/components-chromium/neon-animation/animations/fade-in-animation.js"
type="chrome_html" />
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment