Slide 1

Slide 1 text

but you’re bringing me down i you

Slide 2

Slide 2 text

@notwaldorf

Slide 3

Slide 3 text

emojineer

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

type=date not working properly empty input is invalid regardless of minlength type=number doesn’t work with pattern type=number can type eee without firing event weird caret offset with type=search typing moves cursor to the end

Slide 7

Slide 7 text

story time

Slide 8

Slide 8 text

1993 the early years

Slide 9

Slide 9 text

1993

Slide 10

Slide 10 text

1995 html2

Slide 11

Slide 11 text

1995

Slide 12

Slide 12 text

1995 checkbox text password radio image hidden submit reset file

Slide 13

Slide 13 text

1995 checkbox text password radio image hidden submit reset file

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

(710, 303)

Slide 16

Slide 16 text

Slide 17

Slide 17 text

Slide 18

Slide 18 text

No content

Slide 19

Slide 19 text

No content

Slide 20

Slide 20 text

No content

Slide 21

Slide 21 text

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

No content

Slide 24

Slide 24 text

No content

Slide 25

Slide 25 text

No content

Slide 26

Slide 26 text

cool cool cool because input

Slide 27

Slide 27 text

1995 1999 bit slow, tbh -

Slide 28

Slide 28 text

in which input does a lot of suffering

Slide 29

Slide 29 text

An element satisfies its constraints if it is not suffering

Slide 30

Slide 30 text

Suffering from being missing

Slide 31

Slide 31 text

Suffering from being too short

Slide 32

Slide 32 text

Suffering from being too long

Slide 33

Slide 33 text

Suffering from a step mismatch

Slide 34

Slide 34 text

Suffering.

Slide 35

Slide 35 text

html4 1999

Slide 36

Slide 36 text

1999

Slide 37

Slide 37 text

No content

Slide 38

Slide 38 text

No content

Slide 39

Slide 39 text

No content

Slide 40

Slide 40 text

cool cool cool because input

Slide 41

Slide 41 text

html5 2011

Slide 42

Slide 42 text

2011 week/month color date/time number range search email tel url

Slide 43

Slide 43 text

2016 week/month color date/time number range search email tel url

Slide 44

Slide 44 text

2011 week/month color date/time number range search email tel url

Slide 45

Slide 45 text

but, as we know, CSS

Slide 46

Slide 46 text

No content

Slide 47

Slide 47 text

input[type=range] { … } // Webkit ::-webkit-slider-thumb { … } ::-webkit-slider-runnable-track { … } // FF ::-moz-range-thumb { … } ::-moz-range-track { … } // Never stop being different, IE <3 ::-ms-thumb { … } ::-ms-track { … } ::-ms-fill-lower { … } ::-ms-fill-upper { … }

Slide 48

Slide 48 text

input[type=range] { … } // Webkit ::-webkit-slider-thumb { … } ::-webkit-slider-runnable-track { … } // FF ::-moz-range-thumb { … } ::-moz-range-track { … } // Never stop being different, IE <3 ::-ms-thumb { … } ::-ms-track { … } ::-ms-fill-lower { … } ::-ms-fill-upper { … }

Slide 49

Slide 49 text

input[type=range] { … } // Webkit ::-webkit-slider-thumb { … } ::-webkit-slider-runnable-track { … } // FF ::-moz-range-thumb { … } ::-moz-range-track { … } // Never stop being different, IE <3 ::-ms-thumb { … } ::-ms-track { … } ::-ms-fill-lower { … } ::-ms-fill-upper { … }

Slide 50

Slide 50 text

input[type=range] { … } // Webkit ::-webkit-slider-thumb { … } ::-webkit-slider-runnable-track { … } // FF ::-moz-range-thumb { … } ::-moz-range-track { … } // Never stop being different, IE <3 ::-ms-thumb { … } ::-ms-track { … } ::-ms-fill-lower { … } ::-ms-fill-upper { … }

Slide 51

Slide 51 text

No content

Slide 52

Slide 52 text

No content

Slide 53

Slide 53 text

but as we know,
 JavaScript

Slide 54

Slide 54 text

Slide 55

Slide 55 text

value = “1234”

Slide 56

Slide 56 text

value = “1234” value = “”

Slide 57

Slide 57 text

value = “1234” value = “” value = “”

Slide 58

Slide 58 text

wait for it

Slide 59

Slide 59 text

is an HTMLInputElement

Slide 60

Slide 60 text

is an HTMLInputElement is an HTMLInputElement

Slide 61

Slide 61 text

is an HTMLInputElement is an HTMLInputElement is an HTMLInputElement

Slide 62

Slide 62 text

No content

Slide 63

Slide 63 text

No content

Slide 64

Slide 64 text

No content

Slide 65

Slide 65 text

Slide 66

Slide 66 text

Slide 67

Slide 67 text

$(‘input[type=checkbox]’).checked

Slide 68

Slide 68 text

$(‘input[type=checkbox]’).checked = false

Slide 69

Slide 69 text

$(‘input[type=number]’)

Slide 70

Slide 70 text

$(‘input[type=number]’).checked

Slide 71

Slide 71 text

$(‘input[type=number]’).checked = true

Slide 72

Slide 72 text

No content

Slide 73

Slide 73 text

No content

Slide 74

Slide 74 text

cool cool cool because input

Slide 75

Slide 75 text

let’s do better

Slide 76

Slide 76 text

Slide 77

Slide 77 text

Slide 78

Slide 78 text

a new hope 2012

Slide 79

Slide 79 text

web components 2012

Slide 80

Slide 80 text

we reusable things

Slide 81

Slide 81 text

we encapsulation

Slide 82

Slide 82 text

No content

Slide 83

Slide 83 text

No content

Slide 84

Slide 84 text

how?

Slide 85

Slide 85 text

Slide 86

Slide 86 text

Slide 87

Slide 87 text

Slide 88

Slide 88 text

what do we need?

Slide 89

Slide 89 text

what do we need? specs!

Slide 90

Slide 90 text

encapsulation shadow DOM 1

Slide 91

Slide 91 text

reusability document.registerElement 2

Slide 92

Slide 92 text

imports 3

Slide 93

Slide 93 text

but like, with code

Slide 94

Slide 94 text

Slide 95

Slide 95 text

class NumberInput extends HTMLElement { constructor() {…} createdCallback() {…} attachedCallback() {…} attributeChanged(which, oldV, newV) {} getValue() {…} setValue(v) {…} } document.registerElement(‘number-input’, NumberInput);

Slide 96

Slide 96 text

class NumberInput extends HTMLElement { constructor() {…} createdCallback() {…} attachedCallback() {…} attributeChanged(which, oldV, newV) {} getValue() {…} setValue(v) {…} } document.registerElement(‘number-input’, NumberInput);

Slide 97

Slide 97 text

class NumberInput extends HTMLElement { constructor() {…} createdCallback() {…} attachedCallback() {…} attributeChanged(which, oldV, newV) {} getValue() {…} setValue(v) {…} } document.registerElement(‘number-input’, NumberInput);

Slide 98

Slide 98 text

class NumberInput extends HTMLElement { constructor() {…} createdCallback() {…} attachedCallback() {…} attributeChanged(which, oldV, newV) {} getValue() {…} setValue(v) {…} } document.registerElement(‘number-input’, NumberInput);

Slide 99

Slide 99 text

class NumberInput extends HTMLElement { constructor() {…} createdCallback() {…} attachedCallback() {…} attributeChanged(which, oldV, newV) {} getValue() {…} setValue(v) {…} } document.registerElement(‘number-input’, NumberInput); createdCallback() { this._value = null; }

Slide 100

Slide 100 text

class NumberInput extends HTMLElement { constructor() {…} createdCallback() {…} attachedCallback() {…} attributeChanged(which, oldV, newV) {} getValue() {…} setValue(v) {…} } document.registerElement(‘number-input’, NumberInput); attachedCallback() { this._input = document.createElement('input'); this._input = 'text'; this._input = this._value; this.createShadowRoot().appendChild(this._input); this._input.addEventListener(‘keypress’, _restrict); this._input.addEventListener(‘input’, _onInput); }

Slide 101

Slide 101 text

class NumberInput extends HTMLElement { constructor() {…} createdCallback() {…} attachedCallback() {…} attributeChanged(which, oldV, newV) {} getValue() {…} setValue(v) {…} } document.registerElement(‘number-input’, NumberInput); attachedCallback() { this._input = document.createElement('input'); this._input = 'text'; this._input = this._value; this.createShadowRoot().appendChild(this._input); this._input.addEventListener(‘keypress’, _restrict); this._input.addEventListener(‘input’, _onInput); }

Slide 102

Slide 102 text

class NumberInput extends HTMLElement { constructor() {…} createdCallback() {…} attachedCallback() {…} attributeChanged(which, oldV, newV) {} getValue() {…} setValue(v) {…} } document.registerElement(‘number-input’, NumberInput); attachedCallback() { this._input = document.createElement('input'); this._input = 'text'; this._input = this._value; this.createShadowRoot().appendChild(this._input); this._input.addEventListener(‘keypress’, _restrict); this._input.addEventListener(‘input’, _onInput); }

Slide 103

Slide 103 text

class NumberInput extends HTMLElement { constructor() {…} createdCallback() {…} attachedCallback() {…} attributeChanged(which, oldV, newV) {} getValue() {…} setValue(v) {…} } document.registerElement(‘number-input’, NumberInput); attachedCallback() { this._input = document.createElement('input'); this._input = 'text'; this._input = this._value; this.createShadowRoot().appendChild(this._input); this._input.addEventListener(‘keypress’, _restrict); this._input.addEventListener(‘input’, _onInput); }

Slide 104

Slide 104 text

class NumberInput extends HTMLElement { constructor() {…} createdCallback() {…} attachedCallback() {…} attributeChanged(which, oldV, newV) {} getValue() {…} setValue(v) {…} } document.registerElement(‘number-input’, NumberInput); getValue() { return this._value; }

Slide 105

Slide 105 text

class NumberInput extends HTMLElement { constructor() {…} createdCallback() {…} attachedCallback() {…} attributeChanged(which, oldV, newV) {} getValue() {…} setValue(v) {…} } document.registerElement(‘number-input’, NumberInput); setValue(v) { this._input.value = this._value = this._fix(v); } getValue() { return this._value; }

Slide 106

Slide 106 text

class NumberInput extends HTMLElement { constructor() {…} createdCallback() {…} attachedCallback() {…} attributeChanged(which, oldV, newV) {} getValue() {…} setValue(v) {…} } document.registerElement(‘number-input’, NumberInput); _fix(value) { if (!value) return null; if (awfulRegex.test(value)) return Number(value); return NaN; }

Slide 107

Slide 107 text

class NumberInput extends HTMLElement { constructor() {…} createdCallback() {…} attachedCallback() {…} attributeChanged(which, oldV, newV) {} getValue() {…} setValue(v) {…} } document.registerElement(‘number-input’, NumberInput); attributeChangedCallback(which, oldV, newV) { if (which == 'value') { this._input.value = newV; } }

Slide 108

Slide 108 text

No content

Slide 109

Slide 109 text

when do we get it? now! sort of.

Slide 110

Slide 110 text

when do we get it? ~~polyfills~~

Slide 111

Slide 111 text

cool cool cool

Slide 112

Slide 112 text

Slide 113

Slide 113 text

@notwaldorf