update components
This commit is contained in:
parent
46ceec311d
commit
89c9a7b669
38 changed files with 1530 additions and 316 deletions
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "iron-input",
|
||||
"version": "1.0.7",
|
||||
"version": "1.0.8",
|
||||
"description": "An input element with data binding",
|
||||
"authors": [
|
||||
"The Polymer Authors"
|
||||
|
@ -31,11 +31,11 @@
|
|||
"web-component-tester": "polymer/web-component-tester#^3.4.0",
|
||||
"webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0"
|
||||
},
|
||||
"_release": "1.0.7",
|
||||
"_release": "1.0.8",
|
||||
"_resolution": {
|
||||
"type": "version",
|
||||
"tag": "v1.0.7",
|
||||
"commit": "7ba38f9121694d72b7390567cb91b6ac18141d2b"
|
||||
"tag": "1.0.8",
|
||||
"commit": "55d2b39ead32b8d90da538daa1a6681fd9ae89d9"
|
||||
},
|
||||
"_source": "git://github.com/PolymerElements/iron-input.git",
|
||||
"_target": "^1.0.0",
|
||||
|
|
|
@ -11,7 +11,7 @@ env:
|
|||
- secure: SvsE+VQL35CZ967ZVy0+7o5xclnBM8egjhsjNRG7WxVPZQboCQ3Xwm8tIDQSWeagM3ZQRkTGca4ta91F1ZEhm4Jdt5CwKhhSNC6JgS3CX819r9UKgUnSS3nvWdqcZq4GXcMoOZm4qE9ttd3xdoKCfkLRQlEGAvM2TEw69mBhj24=
|
||||
node_js: 4
|
||||
addons:
|
||||
firefox: '42.0'
|
||||
firefox: latest
|
||||
apt:
|
||||
sources:
|
||||
- google-chrome
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "iron-input",
|
||||
"version": "1.0.7",
|
||||
"version": "1.0.8",
|
||||
"description": "An input element with data binding",
|
||||
"authors": [
|
||||
"The Polymer Authors"
|
||||
|
|
|
@ -69,15 +69,17 @@ is separate from validation, and `allowed-pattern` does not affect how the input
|
|||
|
||||
/**
|
||||
* Set to true to prevent the user from entering invalid input. The new input characters are
|
||||
* matched with `allowedPattern` if it is set, otherwise it will use the `pattern` attribute if
|
||||
* set, or the `type` attribute (only supported for `type=number`).
|
||||
* matched with `allowedPattern` if it is set, otherwise it will use the `type` attribute (only
|
||||
* supported for `type=number`).
|
||||
*/
|
||||
preventInvalidInput: {
|
||||
type: Boolean
|
||||
},
|
||||
|
||||
/**
|
||||
* Regular expression to match valid input characters.
|
||||
* Regular expression expressing a set of characters to enforce the validity of input characters.
|
||||
* The recommended value should follow this format: `[a-ZA-Z0-9.+-!;:]` that list the characters
|
||||
* allowed as input.
|
||||
*/
|
||||
allowedPattern: {
|
||||
type: String,
|
||||
|
@ -105,8 +107,6 @@ is separate from validation, and `allowed-pattern` does not affect how the input
|
|||
var pattern;
|
||||
if (this.allowedPattern) {
|
||||
pattern = new RegExp(this.allowedPattern);
|
||||
} else if (this.pattern) {
|
||||
pattern = new RegExp(this.pattern);
|
||||
} else {
|
||||
switch (this.type) {
|
||||
case 'number':
|
||||
|
@ -126,7 +126,7 @@ is separate from validation, and `allowed-pattern` does not affect how the input
|
|||
*/
|
||||
_bindValueChanged: function() {
|
||||
if (this.value !== this.bindValue) {
|
||||
this.value = !(this.bindValue || this.bindValue === 0) ? '' : this.bindValue;
|
||||
this.value = !(this.bindValue || this.bindValue === 0 || this.bindValue === false) ? '' : this.bindValue;
|
||||
}
|
||||
// manually notify because we don't want to notify until after setting value
|
||||
this.fire('bind-value-changed', {value: this.bindValue});
|
||||
|
@ -235,8 +235,8 @@ is separate from validation, and `allowed-pattern` does not affect how the input
|
|||
if (this.hasValidator()) {
|
||||
valid = Polymer.IronValidatableBehavior.validate.call(this, this.value);
|
||||
} else {
|
||||
this.invalid = !this.validity.valid;
|
||||
valid = this.validity.valid;
|
||||
valid = this.checkValidity();
|
||||
this.invalid = !valid;
|
||||
}
|
||||
this.fire('iron-input-validate');
|
||||
return valid;
|
||||
|
|
|
@ -1,14 +1,11 @@
|
|||
<!doctype html>
|
||||
<!--
|
||||
<!DOCTYPE html><!--
|
||||
Copyright (c) 2014 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>
|
||||
--><html><head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
|
||||
<title>iron-input ests</title>
|
||||
|
@ -18,7 +15,9 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
|||
<script>
|
||||
WCT.loadSuites([
|
||||
'iron-input.html',
|
||||
'iron-input.html?dom=shadow'
|
||||
]);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
</body></html>
|
||||
|
|
|
@ -44,19 +44,25 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
|||
|
||||
<test-fixture id="prevent-invalid-input">
|
||||
<template>
|
||||
<input is="iron-input" prevent-invalid-input pattern="[0-9]">
|
||||
<input is="iron-input" prevent-invalid-input allowed-pattern="[0-9]">
|
||||
</template>
|
||||
</test-fixture>
|
||||
|
||||
<test-fixture id="prevent-invalid-input-with-pattern">
|
||||
<template>
|
||||
<input is="iron-input" prevent-invalid-input pattern="[a-zA-Z]{3}[0-9]*">
|
||||
</template>
|
||||
</test-fixture>
|
||||
|
||||
<test-fixture id="prevent-invalid-input-has-value">
|
||||
<template>
|
||||
<input is="iron-input" prevent-invalid-input pattern="[0-9]*" value="foobar">
|
||||
<input is="iron-input" prevent-invalid-input allowed-pattern="[0-9]" value="foobar">
|
||||
</template>
|
||||
</test-fixture>
|
||||
|
||||
<test-fixture id="prevent-invalid-input-has-bind-value">
|
||||
<template>
|
||||
<input is="iron-input" prevent-invalid-input pattern="[0-9]*" bind-value="foobar">
|
||||
<input is="iron-input" prevent-invalid-input allowed-pattern="[0-9]" bind-value="foobar">
|
||||
</template>
|
||||
</test-fixture>
|
||||
|
||||
|
@ -66,6 +72,12 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
|||
</template>
|
||||
</test-fixture>
|
||||
|
||||
<test-fixture id="no-validator">
|
||||
<template>
|
||||
<input is="iron-input" pattern="[a-zA-Z]{3}[0-9]*">
|
||||
</template>
|
||||
</test-fixture>
|
||||
|
||||
<test-fixture id="has-validator">
|
||||
<template>
|
||||
<letters-only></letters-only>
|
||||
|
@ -116,6 +128,26 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
|||
assert.ok(!scope.$.input.value, 'value is falsy');
|
||||
});
|
||||
|
||||
test('can validate using a complex regex', function() {
|
||||
var input = fixture('no-validator');
|
||||
input.value = '123';
|
||||
input.validate();
|
||||
assert.isTrue(input.invalid, 'input is invalid');
|
||||
input.value = 'foo';
|
||||
input.validate();
|
||||
assert.isFalse(input.invalid, 'input is valid');
|
||||
input.value = 'foo123';
|
||||
input.validate();
|
||||
assert.isFalse(input.invalid, 'input is valid');
|
||||
});
|
||||
|
||||
test('set bindValue to false', function() {
|
||||
var scope = document.getElementById('bind-to-object');
|
||||
scope.foo = false;
|
||||
assert.isFalse(scope.$.input.bindValue);
|
||||
assert.equal(scope.$.input.value, 'false');
|
||||
});
|
||||
|
||||
test('validator used instead of constraints api if provided', function() {
|
||||
var input = fixture('has-validator')[1];
|
||||
input.value = '123';
|
||||
|
@ -134,6 +166,27 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
|||
assert.equal(input.bindValue, '123');
|
||||
});
|
||||
|
||||
test('inputs can be validated', function() {
|
||||
var input = fixture('prevent-invalid-input-with-pattern');
|
||||
input.value = '123';
|
||||
input._onInput();
|
||||
assert.equal(input.bindValue, '123');
|
||||
input.validate();
|
||||
assert.isTrue(input.invalid, 'input is invalid');
|
||||
|
||||
input.value = 'foo';
|
||||
input._onInput();
|
||||
assert.equal(input.bindValue, 'foo');
|
||||
input.validate();
|
||||
assert.isFalse(input.invalid, 'input is valid');
|
||||
|
||||
input.value = 'foo123';
|
||||
input._onInput();
|
||||
assert.equal(input.bindValue, 'foo123');
|
||||
input.validate();
|
||||
assert.isFalse(input.invalid, 'input is valid');
|
||||
});
|
||||
|
||||
test('prevent invalid input works automatically when allowed pattern is set', function() {
|
||||
var input = fixture('automatically-prevent-invalid-input-if-allowed-pattern');
|
||||
input.value = '123';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue