-
Notifications
You must be signed in to change notification settings - Fork 85
/
PickerElement.js
33 lines (28 loc) · 1018 Bytes
/
PickerElement.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import SveltePicker from './components/Picker/Picker.svelte'
import { mark } from '../shared/marks'
import { log } from '../shared/log'
export default class Picker extends SveltePicker {
constructor (props) {
mark('initialLoad')
// Make the API simpler, directly pass in the props
super({ props })
}
disconnectedCallback () {
// Have to explicitly destroy the component to avoid memory leaks.
// See https://github.com/sveltejs/svelte/issues/1152
log('disconnectedCallback')
this.$destroy()
}
static get observedAttributes () {
return ['locale', 'data-source', 'skin-tone-emoji'] // complex objects aren't supported, also use kebab-case
}
// via https://github.com/sveltejs/svelte/issues/3852#issuecomment-665037015
attributeChangedCallback (attrName, oldValue, newValue) {
super.attributeChangedCallback(
attrName.replace(/-([a-z])/g, (_, up) => up.toUpperCase()),
oldValue,
newValue
)
}
}
customElements.define('emoji-picker', Picker)