Skip to content

Commit 332c54b

Browse files
committed
Merge branch 'develop'
2 parents 988c67b + b76778b commit 332c54b

File tree

3 files changed

+54
-38
lines changed

3 files changed

+54
-38
lines changed

README.md

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44

55
An accessible polyfill for `<input type='time'/>` elements.
66

7-
- ✔️ Modeled after the Chrome and Firefox implementations
8-
- ✔️ Fully keyboard and screen reader accessible
9-
- ✔️ Submits the same values to servers as real time inputs
10-
- ✔️ Only downloads the full polyfill code in the browsers that need it
11-
- ✔️ Zero dependencies
7+
- ✔️ Modeled after the Chrome and Firefox desktop implementations.
8+
- ✔️ Fully keyboard and screen reader accessible.
9+
- ✔️ Submits the same values to servers as real time inputs.
10+
- ✔️ Only downloads the full polyfill code in the browsers that need it.
11+
- ✔️ Zero dependencies.
1212

1313
Demo available here: https://dan503.github.io/time-input-polyfill/
1414

@@ -22,7 +22,7 @@ Add the following script element to your page:
2222
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
2323
```
2424

25-
Alternatively you can download it via npm and use it through commonJS
25+
Alternatively you can download it via npm and use it through commonJS or an ES6 import statement.
2626

2727
```
2828
npm i time-input-polyfill
@@ -31,7 +31,11 @@ npm i time-input-polyfill
3131
Then require it in your main JavaScript file like so:
3232

3333
```js
34-
require('time-input-polyfill/auto')
34+
// ES5
35+
require('time-input-polyfill/auto');
36+
37+
// ES6
38+
import 'time-input-polyfill/auto';
3539
```
3640

3741
That's all you need to do.
@@ -44,7 +48,7 @@ You didn't load the actual polyfill onto the page, you loaded a much smaller aut
4448
2. If it **does**, it skips the rest of the functionality.
4549
3. If it does **not**, it will:
4650
1. load `https://cdn.jsdelivr.net/npm/[email protected]/dist/time-input-polyfill.min.js` (the actual polyfill).
47-
2. Collect all `input[type="time"]` elements on the page.
51+
2. Collect all existing `input[type="time"]` elements on the page.
4852
3. Loop through each `input[type="time"]` element and apply the polyfill to it.
4953

5054

@@ -59,7 +63,7 @@ First check for `input[type="time"]` support.
5963
```js
6064
var supportsTime = require('time-input-polyfill/core/helpers/supportsTime');
6165

62-
if (supportsTime) {
66+
if (!supportsTime) {
6367
//Apply polyfill here
6468
}
6569
```
@@ -70,10 +74,10 @@ Then gather a list of all `input[type="time"]` elements on the page, and loop th
7074
var supportsTime = require('time-input-polyfill/core/helpers/supportsTime');
7175
var TimePolyfill = require('time-input-polyfill');
7276

73-
if (supportsTime) {
77+
if (!supportsTime) {
7478
// Converting to an array for IE support
75-
var $inputs = [].slice.call( document.querySelectorAll('input[type="time"]') );
76-
$inputs.forEach(function($input){
79+
var $$inputs = [].slice.call( document.querySelectorAll('input[type="time"]') );
80+
$$inputs.forEach(function($input){
7781
new TimePolyfill($input);
7882
})
7983
}
@@ -89,7 +93,7 @@ First check for `input[type="time"]` support.
8993
<script src="https://cdn.jsdelivr.net/npm/[email protected]/core/helpers/supportsTime.js"></script>
9094
```
9195
```js
92-
if (supportsTime) {
96+
if (!supportsTime) {
9397
//Apply polyfill here
9498
}
9599
```
@@ -101,10 +105,10 @@ Then gather a list of all `input[type="time"]` elements on the page, and loop th
101105
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/time-input-polyfill.min.js"></script>
102106
```
103107
```js
104-
if (supportsTime) {
108+
if (!supportsTime) {
105109
// Converting to an array for IE support
106-
var $inputs = [].slice.call( document.querySelectorAll('input[type="time"]') );
107-
$inputs.forEach(function($input){
110+
var $$inputs = [].slice.call( document.querySelectorAll('input[type="time"]') );
111+
$$inputs.forEach(function($input){
108112
new TimePolyfill($input);
109113
})
110114
}
@@ -122,7 +126,7 @@ In browsers that support the time input natively, they will provide the `value`
122126

123127
If this isn't working for you, you can prevent the auto-swap functionality by setting `$input.polyfill.autoSwap = false`. You can access the current input value in 24 hour time format by reading the `data-value` attribute.
124128

125-
You can also switch the `$input` manually to 24 hour time using `$input.polyfill.swap()`. The polyfill does not function properly at the moment while running in 24 hour time. 24 hour time is only meant to be used as a means of submitting correct values to forms. It is not intended to be used as a permanent mode (at least not yet).
129+
You can also switch the `$input` manually to 24 hour time using `$input.polyfill.swap()`. The polyfill does not function properly at the moment while running in 24 hour time. 24 hour time is only meant to be used as a means of submitting correct values to forms. It is not intended to be used as a permanent mode.
126130

127131
### You must call `$input.polyfill.update()` on dynamic inputs
128132

package-lock.json

Lines changed: 31 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "time-input-polyfill",
3-
"description": "An accessible polyfill for `<input type='time'/>` elements modeled after the Chrome & Firefox implementations.",
4-
"version": "1.0.3",
3+
"description": "An accessible polyfill for `<input type='time'/>` elements modeled after the Chrome & Firefox desktop implementations.",
4+
"version": "1.0.4",
55
"main": "index.js",
66
"jsdelivr": "dist/time-input-polyfill.auto.min.js",
77
"dependencies": {},
@@ -35,7 +35,6 @@
3535
"gulp-util": "~3.0.7",
3636
"imagemin-pngquant": "~4.2.0",
3737
"imagemin-svgo": "~4.2.0",
38-
"jquery": "~2.2.0",
3938
"js-yaml": "~3.5.2",
4039
"lodash": "~4.0.0",
4140
"minimist": "~1.2.0",

0 commit comments

Comments
 (0)