Created
August 27, 2019 09:03
-
-
Save rowan-m/7a8b6a9f0cc2e00c2a391357dba2483a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class InputKnob extends HTMLElement { | |
constructor() { | |
// Nothing to do in here at the moment, but we do need to call the parent | |
// constructor | |
super(); | |
} | |
// Watch for changes on the 'value' attribute | |
static get observedAttributes() { | |
return ['value']; | |
} | |
// Map the JavaScript property to the HTML attribute | |
get value() { | |
return this.hasAttribute('value') ? this.getAttribute('value') : 0; | |
} | |
set value(value) { | |
this.setAttribute('value', value); | |
} | |
// Respond to any changes to the observed attributes | |
attributeChangedCallback(attrName, oldVal, newVal) { | |
// nothing yet | |
} | |
} | |
// Map the class to an element name and make it available to the page! | |
window.customElements.define('input-knob', InputKnob); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment