material 0.6.1 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/index.js +11 -2
  2. package/package.json +1 -1
  3. package/src/appbar.js +28 -28
  4. package/src/banner.js +20 -20
  5. package/src/button.js +18 -19
  6. package/src/calendar.js +8 -8
  7. package/src/card.js +4 -4
  8. package/src/checkbox.js +8 -8
  9. package/src/component.js +4 -4
  10. package/src/container.js +4 -4
  11. package/src/control/button.js +64 -88
  12. package/src/control/button.new.js +25 -25
  13. package/src/control/datehour.js +4 -4
  14. package/src/control/dialog.js +12 -11
  15. package/src/control/file.js +8 -8
  16. package/src/control/image.js +6 -6
  17. package/src/control/link.js +9 -9
  18. package/src/control/list.js +25 -35
  19. package/src/control/loading.js +10 -10
  20. package/src/control/menu.js +85 -0
  21. package/src/control/search.js +9 -9
  22. package/src/control/select.js +6 -6
  23. package/src/control/selecter.js +15 -15
  24. package/src/control/snackbar.js +91 -0
  25. package/src/control/switch.js +18 -18
  26. package/src/control/switcher.js +16 -16
  27. package/src/control/text.js +11 -7
  28. package/src/control/textfield.js +12 -12
  29. package/src/dialog.js +19 -19
  30. package/src/divider.js +4 -4
  31. package/src/drawer.js +11 -11
  32. package/src/element.js +6 -31
  33. package/src/field/email.js +5 -5
  34. package/src/field/image.js +4 -4
  35. package/src/form/build.js +7 -7
  36. package/src/form.js +6 -6
  37. package/src/icon.js +8 -8
  38. package/src/image.js +14 -14
  39. package/src/item.js +7 -7
  40. package/src/layout.js +10 -10
  41. package/src/list/add.js +1 -1
  42. package/src/list/build.js +7 -7
  43. package/src/list/display.js +10 -10
  44. package/src/list/search.js +2 -2
  45. package/src/list.js +13 -13
  46. package/src/map/build.js +6 -6
  47. package/src/map/display.js +8 -8
  48. package/src/menu.js +15 -15
  49. package/src/{component → mixin}/control.js +10 -10
  50. package/src/{component → mixin}/create.js +1 -1
  51. package/src/mixin/display.js +76 -0
  52. package/src/mixin/emitter.js +23 -0
  53. package/src/{component → mixin}/events.js +2 -2
  54. package/src/{component → mixin}/focus.js +2 -3
  55. package/src/{component → mixin}/insert.js +1 -1
  56. package/src/module/build.js +44 -0
  57. package/src/{component → module}/classify.js +0 -13
  58. package/src/module/dataset.js +12 -0
  59. package/src/module/dom.js +1 -57
  60. package/src/module/events.js +57 -0
  61. package/src/module/jsontohtml.js +20 -0
  62. package/src/module/last.js +0 -0
  63. package/src/{component → module}/ripple.js +15 -42
  64. package/src/progress.js +7 -7
  65. package/src/select.js +16 -16
  66. package/src/selector.js +32 -32
  67. package/src/skin/material/control/menu.sass +29 -0
  68. package/src/skin/material/control/snackbar.sass +65 -0
  69. package/src/slider.js +32 -32
  70. package/src/snackbar.js +8 -8
  71. package/src/switch.js +9 -9
  72. package/src/tabs.js +8 -8
  73. package/src/tabview.js +8 -8
  74. package/src/text.js +5 -5
  75. package/src/textfield.js +16 -16
  76. package/src/toolbar.js +28 -28
  77. package/src/tooltip.js +11 -11
  78. package/src/tree.js +12 -16
  79. package/src/view/build.js +7 -7
  80. package/src/view/display.js +16 -16
  81. package/src/view.js +5 -5
  82. package/src/component/click.js +0 -17
  83. /package/src/{component → mixin}/controller.js +0 -0
  84. /package/src/{component → mixin}/icon.js +0 -0
  85. /package/src/{component → mixin}/init.js +0 -0
  86. /package/src/{component → mixin}/label.js +0 -0
  87. /package/src/{component → mixin}/settings.js +0 -0
@@ -1,9 +1,22 @@
1
- import addClass from './module/addclass'
1
+ // menu related modules
2
+ import emitter from '../module/emitter'
3
+ import attach from '../module/attach'
4
+ import build from '../module/build'
5
+ import display from '../module/display'
6
+
7
+ import Layout from '../layout'
8
+ import Element from '../element'
9
+ import Button from './text'
2
10
 
3
11
  const defaults = {
4
- class: 'text',
5
- tag: 'span',
6
- seprator: ' | '
12
+ class: 'list',
13
+ layout: [
14
+ [Element, 'main', { tag: 'ul' }]
15
+ ],
16
+ item: [Text, { tag: 'li' }],
17
+ events: [
18
+ ['ui.main.click', 'select']
19
+ ]
7
20
  }
8
21
 
9
22
  class List {
@@ -14,40 +27,15 @@ class List {
14
27
  */
15
28
  constructor (options) {
16
29
  this.options = Object.assign({}, defaults, options || {})
17
-
18
- // console.log('options', this.options)
30
+ // implement modules
31
+ Object.assign(this, emitter, build, attach, display)
19
32
 
20
33
  this.build()
21
34
 
22
35
  return this
23
36
  }
24
37
 
25
- /**
26
- * Build Method
27
- * @return {Object} This class instance
28
- */
29
- build () {
30
- this.root = document.createElement(this.options.tag)
31
- addClass(this.root, this.options.class)
32
-
33
- if (this.options.class !== 'text') {
34
- this.root.classList.add('text')
35
- }
36
-
37
- if (this.options.list) {
38
- this.set(this.options.list)
39
- }
40
-
41
- if (this.options.container) {
42
- this.options.container.appendChild(this.root)
43
- }
44
-
45
- return this
46
- }
47
-
48
- set (list) {
49
- var text = ''
50
-
38
+ add (items) {
51
39
  for (var i = 0; i < list.length; i++) {
52
40
  if (i < list.length - 1) {
53
41
  text = text + list[i] + this.options.seprator
@@ -61,16 +49,18 @@ class List {
61
49
 
62
50
  var label = this.options.label || ''
63
51
 
64
- this.root.innerHTML = label + text
52
+ this.element.innerHTML = label + text
65
53
 
66
54
  if (this.options.spaceAfter) {
67
- this.root.innerHTML = this.root.innerHTML + ' '
55
+ this.element.innerHTML = this.element.innerHTML + ' '
68
56
  }
69
57
  }
70
58
 
59
+ select()
60
+
71
61
  setText (text) {
72
62
  // console.log('setText', text)
73
- this.root.innerHTML = text
63
+ this.element.innerHTML = text
74
64
  }
75
65
  }
76
66
 
@@ -62,16 +62,16 @@ class Loading {
62
62
  * @return {Object} This class instance
63
63
  */
64
64
  build (options) {
65
- this.root = document.createElement(this.options.tag)
65
+ this.element = document.createElement(this.options.tag)
66
66
  this.classify()
67
67
 
68
68
  if (this.options.type === 'circular') {
69
- this.root.innerHTML = this.options.circular
69
+ this.element.innerHTML = this.options.circular
70
70
  } if (this.options.type === 'indeterminate') {
71
71
  this.bar = document.createElement(this.options.tag)
72
72
  this.bar.classList.add('bar')
73
- this.root.classList.add('type-indeterminate')
74
- this.root.appendChild(this.bar)
73
+ this.element.classList.add('type-indeterminate')
74
+ this.element.appendChild(this.bar)
75
75
  }
76
76
 
77
77
  return this
@@ -79,16 +79,16 @@ class Loading {
79
79
 
80
80
  classify () {
81
81
  if (this.options.class !== 'loading') {
82
- this.root.setAttribute('class', this.options.class + ' ' + this.options.class)
82
+ this.element.setAttribute('class', this.options.class + ' ' + this.options.class)
83
83
  } else {
84
- this.root.classList.add(this.options.class)
84
+ this.element.classList.add(this.options.class)
85
85
  }
86
86
  }
87
87
 
88
88
  append (container) {
89
89
  container = container || this.options.container
90
90
  if (this.options.container) {
91
- container.appendChild(this.root)
91
+ container.appendChild(this.element)
92
92
  }
93
93
  }
94
94
 
@@ -101,7 +101,7 @@ class Loading {
101
101
 
102
102
  clearTimeout(this.showTimeout)
103
103
  this.showTimeout = setTimeout(() => {
104
- this.root.classList.add('show')
104
+ this.element.classList.add('show')
105
105
  }, this.options.delay)
106
106
 
107
107
  this.visible = true
@@ -110,7 +110,7 @@ class Loading {
110
110
  }
111
111
 
112
112
  showNow () {
113
- this.root.classList.add('show')
113
+ this.element.classList.add('show')
114
114
 
115
115
  this.visible
116
116
 
@@ -119,7 +119,7 @@ class Loading {
119
119
 
120
120
  hide () {
121
121
  clearTimeout(this.showTimeout)
122
- this.root.classList.remove('show')
122
+ this.element.classList.remove('show')
123
123
  this.visible = false
124
124
  return this
125
125
  }
@@ -0,0 +1,85 @@
1
+ import EventEmitter from '../mixin/emitter'
2
+ // menu related modules
3
+ import build from '../module/build'
4
+ import bindEvents from '../module/events'
5
+ import display from '../mixin/display'
6
+
7
+ import Element from '../element'
8
+ import Button from './button'
9
+
10
+ class Menu extends EventEmitter {
11
+ static defaults = {
12
+ class: 'menu',
13
+ transition: 200,
14
+ modal: false,
15
+ layout: [
16
+ [Element, 'surface', { class: 'surface' },
17
+ [Element, 'list', { tag: 'ul', class: 'items' }]
18
+ ]
19
+ ],
20
+ events: [
21
+ ['element.click', 'close']
22
+ ]
23
+ };
24
+
25
+ constructor (options) {
26
+ super()
27
+
28
+ this.init(options)
29
+ this.build(this.constructor)
30
+ this.bindEvents()
31
+
32
+ this.render(this.options.items)
33
+ }
34
+
35
+ init(options) {
36
+ this.options = Object.assign({}, Menu.defaults, options || {})
37
+ Object.assign(this, build, bindEvents, display)
38
+ }
39
+
40
+ render (items) {
41
+ if (items && Array.isArray(items)) {
42
+ for (var i = 0; i < items.length; i++) {
43
+ this.add(items[i])
44
+ }
45
+ }
46
+
47
+ return this
48
+ }
49
+
50
+ add (obj) {
51
+ if (typeof obj !== 'object') return this;
52
+ let item;
53
+ if (obj.type === 'divider') {
54
+ item = new Element({ tag: 'li', class: 'divider' })
55
+ } else {
56
+ obj.container = this.ui.list
57
+ obj.class = 'item'
58
+ item = new Button(obj).on('click', (ev) => {
59
+ // console.log('select', ev.target.name)
60
+ this.emit('select', ev.target.name)
61
+ })
62
+ }
63
+
64
+ return this
65
+ }
66
+
67
+ position(target) {
68
+ if (!target) return
69
+ var offs = target.getBoundingClientRect()
70
+
71
+ var offsw = this.offset = this.ui.surface.getBoundingClientRect()
72
+
73
+ this.ui.surface.style.top = (offs.top - 4) + 'px'
74
+ this.ui.surface.style.left = offs.left - offsw.width + offs.width + 'px'
75
+
76
+ return this
77
+ }
78
+
79
+ close() {
80
+ // console.log('close')
81
+ this.destroy()
82
+ }
83
+ }
84
+
85
+ export default Menu
@@ -40,32 +40,32 @@ class Search {
40
40
  * @return {Object} This class instance
41
41
  */
42
42
  build () {
43
- this.root = document.createElement('div')
44
- this.root.classList.add('search')
43
+ this.element = document.createElement('div')
44
+ this.element.classList.add('search')
45
45
 
46
46
  if (this.options.class !== 'search') {
47
- this.root.classList.add(this.options.class)
47
+ this.element.classList.add(this.options.class)
48
48
  }
49
49
 
50
50
  if (this.options.icon) {
51
51
  this.icon = document.createElement('i')
52
52
  this.icon.classList.add('icon')
53
53
  this.icon.innerHTML = this.options.icon
54
- this.root.appendChild(this.icon)
54
+ this.element.appendChild(this.icon)
55
55
  }
56
56
 
57
57
  this.input = document.createElement('input')
58
58
  this.input.classList.add('input')
59
- this.root.appendChild(this.input)
59
+ this.element.appendChild(this.input)
60
60
 
61
61
  this.cancel = new Button({
62
- container: this.root,
62
+ container: this.element,
63
63
  class: 'clear',
64
64
  icon: this.options.iconCancel
65
65
  })
66
66
 
67
67
  if (this.options.container) {
68
- this.options.container.appendChild(this.root)
68
+ this.options.container.appendChild(this.element)
69
69
  }
70
70
 
71
71
  return this
@@ -90,8 +90,8 @@ class Search {
90
90
  }
91
91
 
92
92
  set (email) {
93
- this.root.innerHTML = email
94
- this.root.setAttribute('href', 'mailto:' + email)
93
+ this.element.innerHTML = email
94
+ this.element.setAttribute('href', 'mailto:' + email)
95
95
  }
96
96
  }
97
97
 
@@ -32,18 +32,18 @@ class Select {
32
32
  */
33
33
  build () {
34
34
  var tag = this.options.tag || 'span'
35
- this.root = document.createElement(tag)
36
- this.root.classList.add('select')
35
+ this.element = document.createElement(tag)
36
+ this.element.classList.add('select')
37
37
 
38
38
  if (this.options.class !== 'select') {
39
- this.root.classList.add(this.options.class)
39
+ this.element.classList.add(this.options.class)
40
40
  }
41
41
 
42
42
  this.buildLabel()
43
43
  this.buildInput()
44
44
 
45
45
  if (this.container) {
46
- this.container.appendChild(this.root)
46
+ this.container.appendChild(this.element)
47
47
  }
48
48
 
49
49
  return this
@@ -54,14 +54,14 @@ class Select {
54
54
  this.label = document.createElement('span')
55
55
  this.label.classList.add('label')
56
56
  this.label.innerHTML = this.options.label
57
- this.root.appendChild(this.label)
57
+ this.element.appendChild(this.label)
58
58
  }
59
59
  }
60
60
 
61
61
  buildInput () {
62
62
  this.input = document.createElement('select')
63
63
  this.input.classList.add('input')
64
- this.root.appendChild(this.input)
64
+ this.element.appendChild(this.input)
65
65
 
66
66
  this.input.addEventListener('change', () => {
67
67
  // console.log('change', this.input[this.input.selectedIndex].value)
@@ -51,7 +51,7 @@ class Selecter {
51
51
 
52
52
  setup () {
53
53
  if (this.options.data) {
54
- dataset(this.root, this.options.data)
54
+ dataset(this.element, this.options.data)
55
55
  }
56
56
 
57
57
  // console.log('attribute', this.ui.input, this.options)
@@ -62,7 +62,7 @@ class Selecter {
62
62
  }
63
63
 
64
64
  if (this.options.tooltip) {
65
- this.root.setAttribute('data-tooltip', this.options.tooltip)
65
+ this.element.setAttribute('data-tooltip', this.options.tooltip)
66
66
  }
67
67
 
68
68
  if (this.options.label) {
@@ -72,7 +72,7 @@ class Selecter {
72
72
  this.ui.input.setAttribute('aria-label', this.options.name)
73
73
 
74
74
  if (this.options.case) {
75
- this.root.classList.add(this.options.case + '-case')
75
+ this.element.classList.add(this.options.case + '-case')
76
76
  }
77
77
  }
78
78
  /**
@@ -81,14 +81,14 @@ class Selecter {
81
81
  */
82
82
  build () {
83
83
  var tag = this.options.tag || 'span'
84
- this.root = document.createElement(tag)
85
- this.root.classList.add('selecter')
84
+ this.element = document.createElement(tag)
85
+ this.element.classList.add('selecter')
86
86
 
87
87
  if (this.options.class !== 'selecter') {
88
- addClass(this.root, this.options.class)
88
+ addClass(this.element, this.options.class)
89
89
  }
90
90
 
91
- this.layout = new Layout(this.options.layout, this.root)
91
+ this.layout = new Layout(this.options.layout, this.element)
92
92
  this.ui = this.layout.component
93
93
 
94
94
  // console.log('ui', this.ui)
@@ -99,7 +99,7 @@ class Selecter {
99
99
  this.setList(this.options.list)
100
100
 
101
101
  if (this.options.container) {
102
- this.options.container.appendChild(this.root)
102
+ this.options.container.appendChild(this.element)
103
103
  }
104
104
  }
105
105
 
@@ -110,13 +110,13 @@ class Selecter {
110
110
  this.ui.icon.classList.add('icon')
111
111
  this.ui.icon.innerHTML = this.options.icon
112
112
 
113
- this.root.insertBefore(this.ui.icon, this.ui.input)
113
+ this.element.insertBefore(this.ui.icon, this.ui.input)
114
114
  }
115
115
 
116
116
  buildInput () {
117
117
  this.input = document.createElement('select')
118
118
  this.input.classList.add('input')
119
- this.root.appendChild(this.input)
119
+ this.element.appendChild(this.input)
120
120
 
121
121
  this.input.addEventListener('change', () => {
122
122
  // console.log('change', this.input[this.input.selectedIndex].value)
@@ -154,19 +154,19 @@ class Selecter {
154
154
 
155
155
  styleAttributes () {
156
156
  if (this.options.style) {
157
- this.root.classList.add('style-' + this.options.style)
157
+ this.element.classList.add('style-' + this.options.style)
158
158
  }
159
159
 
160
160
  if (this.options.size) {
161
- this.root.classList.add(this.options.size + '-size')
161
+ this.element.classList.add(this.options.size + '-size')
162
162
  }
163
163
 
164
164
  if (this.options.color) {
165
- this.root.classList.add('color-' + this.options.color)
165
+ this.element.classList.add('color-' + this.options.color)
166
166
  }
167
167
 
168
168
  if (this.options.bold) {
169
- this.root.classList.add('bold')
169
+ this.element.classList.add('bold')
170
170
  }
171
171
  }
172
172
  showList () {
@@ -216,7 +216,7 @@ class Selecter {
216
216
  this.ui.value.innerHTML = this.values[value]
217
217
  }
218
218
 
219
- this.selected = this.root.querySelector('[data-value=' + value + ']')
219
+ this.selected = this.element.querySelector('[data-value=' + value + ']')
220
220
 
221
221
  // console.log('item', this.selected)
222
222
  if (this.selected) {
@@ -0,0 +1,91 @@
1
+ // base class
2
+ import EventEmitter from '../mixin/emitter'
3
+ // related modules
4
+ import build from '../module/build'
5
+ import bindEvents from '../module/events'
6
+ import display from '../mixin/display'
7
+ // ui element
8
+ import Text from './text'
9
+ import Button from './button'
10
+
11
+ class Snackbar extends EventEmitter {
12
+ static defaults = {
13
+ class: 'snackbar',
14
+ transition: 225,
15
+ duration: 4000,
16
+ close: false,
17
+ layout: [
18
+ [Text, 'text', { tag: 'span', class: 'text' }],
19
+ [Button, 'action', { class: 'action', type: 'link' }],
20
+ [Button, 'close', { class: 'close', type: 'action' }]
21
+ ],
22
+ events: [
23
+ ['ui.action.click', 'action'],
24
+ ['ui.close.click', 'destroy']
25
+ ]
26
+ };
27
+
28
+ constructor (options) {
29
+ super()
30
+
31
+ this.init(options)
32
+ this.build(this.constructor)
33
+ this.render()
34
+ this.bindEvents()
35
+ this.show()
36
+
37
+ if (this.options.duration)
38
+ setTimeout(()=>{
39
+ this.destroy()
40
+ }, this.options.duration)
41
+ }
42
+
43
+ init(options) {
44
+ this.options = Object.assign({}, Snackbar.defaults, options || {})
45
+ Object.assign(this, build, bindEvents, display)
46
+
47
+ this.buildSnackbarContainer(this.options.container)
48
+ }
49
+
50
+ buildSnackbarContainer (container = document.body) {
51
+ // console.log('buildSnackbarContainer', container)
52
+
53
+ let snackbarContainer = container.querySelector('.snackbars')
54
+
55
+ // console.log('snackbarContainer', snackbarContainer)
56
+
57
+ if (!snackbarContainer) {
58
+ this.options.container = document.createElement('div')
59
+ this.options.container.classList.add('snackbars')
60
+ container.appendChild(this.options.container)
61
+ } else {
62
+ this.options.container = snackbarContainer
63
+ }
64
+ }
65
+
66
+ render () {
67
+ this.ui.text.set(this.options.text)
68
+
69
+ if (this.options.action) {
70
+ this.ui.action.set(this.options.action)
71
+ this.ui.action.element.classList.add('show')
72
+ }
73
+
74
+ if (this.options.close) this.ui.close.element.classList.add('show')
75
+
76
+ return this
77
+ }
78
+
79
+ action () {
80
+ // console.log('action')
81
+ this.emit('action')
82
+ this.destroy()
83
+ }
84
+
85
+ close() {
86
+ // console.log('close')
87
+ this.destroy()
88
+ }
89
+ }
90
+
91
+ export default Snackbar
@@ -50,14 +50,14 @@ class Switch {
50
50
  */
51
51
  build () {
52
52
  var tag = this.options.tag || 'span'
53
- this.root = document.createElement(tag)
54
- this.root.classList.add('switch')
53
+ this.element = document.createElement(tag)
54
+ this.element.classList.add('switch')
55
55
 
56
56
  if (this.options.class !== 'switch') {
57
- addClass(this.root, this.options.class)
57
+ addClass(this.element, this.options.class)
58
58
  }
59
59
 
60
- this.layout = new Layout(this.options.layout, this.root)
60
+ this.layout = new Layout(this.options.layout, this.element)
61
61
  this.ui = this.layout.component
62
62
 
63
63
  // console.log('ui', this.ui)
@@ -68,13 +68,13 @@ class Switch {
68
68
  this.buildLabel()
69
69
 
70
70
  if (this.options.container) {
71
- this.options.container.appendChild(this.root)
71
+ this.options.container.appendChild(this.element)
72
72
  }
73
73
  }
74
74
 
75
75
  setup () {
76
76
  if (this.options.data) {
77
- dataset(this.root, this.options.data)
77
+ dataset(this.element, this.options.data)
78
78
  }
79
79
 
80
80
  // console.log('attribute', this.ui.input, this.options)
@@ -89,13 +89,13 @@ class Switch {
89
89
  }
90
90
 
91
91
  if (this.options.tooltip) {
92
- this.root.setAttribute('data-tooltip', this.options.tooltip)
92
+ this.element.setAttribute('data-tooltip', this.options.tooltip)
93
93
  }
94
94
 
95
95
  this.ui.input.setAttribute('aria-label', this.options.name)
96
96
 
97
97
  if (this.options.case) {
98
- this.root.classList.add(this.options.case + '-case')
98
+ this.element.classList.add(this.options.case + '-case')
99
99
  }
100
100
  }
101
101
 
@@ -111,7 +111,7 @@ class Switch {
111
111
  this.ui.label.setAttribute('for', this.options.name)
112
112
  }
113
113
 
114
- this.root.insertBefore(this.ui.label, this.ui.input)
114
+ this.element.insertBefore(this.ui.label, this.ui.input)
115
115
  }
116
116
 
117
117
  buildIcon () {
@@ -121,24 +121,24 @@ class Switch {
121
121
  this.ui.icon.classList.add('icon')
122
122
  this.ui.icon.innerHTML = this.options.icon
123
123
 
124
- this.root.insertBefore(this.ui.icon, this.ui.input)
124
+ this.element.insertBefore(this.ui.icon, this.ui.input)
125
125
  }
126
126
 
127
127
  styleAttributes () {
128
128
  if (this.options.style) {
129
- this.root.classList.add('style-' + this.options.style)
129
+ this.element.classList.add('style-' + this.options.style)
130
130
  }
131
131
 
132
132
  if (this.options.size) {
133
- this.root.classList.add(this.options.size + '-size')
133
+ this.element.classList.add(this.options.size + '-size')
134
134
  }
135
135
 
136
136
  if (this.options.color) {
137
- this.root.classList.add('color-' + this.options.color)
137
+ this.element.classList.add('color-' + this.options.color)
138
138
  }
139
139
 
140
140
  if (this.options.bold) {
141
- this.root.classList.add('bold')
141
+ this.element.classList.add('bold')
142
142
  }
143
143
  }
144
144
 
@@ -228,7 +228,7 @@ class Switch {
228
228
  check (checked, silent) {
229
229
  // console.log('check', checked, silent)
230
230
  if (checked === true) {
231
- this.root.classList.add('is-checked')
231
+ this.element.classList.add('is-checked')
232
232
  this.ui.input.checked = true
233
233
  this.checked = true
234
234
  this.value = true
@@ -236,7 +236,7 @@ class Switch {
236
236
  this.emit('change', this.checked)
237
237
  }
238
238
  } else {
239
- this.root.classList.remove('is-checked')
239
+ this.element.classList.remove('is-checked')
240
240
  this.ui.input.checked = false
241
241
  this.checked = false
242
242
  this.value = false
@@ -254,7 +254,7 @@ class Switch {
254
254
  focus () {
255
255
  if (this.disabled === true) return this
256
256
 
257
- this.root.classList.add('is-focused')
257
+ this.element.classList.add('is-focused')
258
258
  if (this.ui.input !== document.activeElement) { this.ui.input.focus() }
259
259
  return this
260
260
  }
@@ -264,7 +264,7 @@ class Switch {
264
264
  * @return {?} [description]
265
265
  */
266
266
  blur () {
267
- this.root.classList.remove('is-focused')
267
+ this.element.classList.remove('is-focused')
268
268
  return this
269
269
  }
270
270
  }