github / github/relative-time-element
Stricter `datetime` validation
- Lingua principale
- JavaScript
- Stelle
- 4k
- Fork
- 192
- Merge medio
- 1g 10h
- PR unite (30g)
- 5
Descrizione
The [docs about the `datetime`](https://github.com/github/relative-time-element#datetime-string) attribute say:
> This must be a valid [ISO8601 DateTime](https://en.wikipedia.org/wiki/ISO_8601)
This statement is incorrect. Any value that can be passed to the [`Date` constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date#date_time_string_format) will work which presents a cross-browser issue because JS engines are inconsistent in which formats their `Date` constructor accept.
For example, the golang default string representation only parses in v8:
```bash
$ eshost -e "new Date('2009-11-10 23:00:00+00:00 UTC')"
#### JavaScriptCore
Invalid Date
#### spidermonkey
Invalid Date
#### v8
Wed Nov 11 2009 00:00:00 GMT+0100 (Central European Standard Time)
```
Also try [this fiddle](https://jsfiddle.net/silverwind/m425n0yg/) in multiple browsers.
How about adding an option attribute to pass in a validation regex into the element to validate the passed dates, when present? This would at least not make this issue missable by developers who only test in Chrome.
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inizia dalla documentazione dell’attributo datetime e dal comportamento del costruttore Date di JavaScript descritto nell’issue, quindi confronta gli esempi cross-browser collegati. Definisci il comportamento della convalida e di regex-option, incluso cosa dovrebbe accadere per le stringhe di data incoerenti; il lavoro è completo quando il comportamento previsto è documentato e convalidato nei browser interessati.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- javascript
- Ambito
- frontend, web-dev
- Tipo di issue
- Funzionalità
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Attiva
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 38/100