/**
* Copyright 2017 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
(function() {
/**
* Define key codes to help with handling keyboard events.
*/
const KEYCODE = {
SPACE: 32,
ENTER: 13,
};
/**
* Cloning contents from a <template> element is more performant
* than using innerHTML because it avoids addtional HTML parse costs.
*/
const template = document.createElement('template');
template.innerHTML = `
<style>
:host {
display: inline-block;
}
:host([hidden]) {
display: none;
}
</style>
<slot></slot>
`;
// HIDE
// ShadyCSS will rename classes as needed to ensure style scoping.
////////////////ShadyCSS.prepareTemplate(template, 'howto-toggle-button');
// /HIDE
class HowToToggleButton extends HTMLElement {
static get observedAttributes() {
return ['pressed', 'disabled'];
}
/**
* The element's constructor is run anytime a new instance is created.
* Instances are created either by parsing HTML, calling
* document.createElement('howto-toggle-button'), or calling new HowToToggleButton();
* The construtor is a good place to create shadow DOM, though you should
* avoid touching any attributes or light DOM children as they may not
* be available yet.
*/
constructor() {
super();
this.attachShadow({mode: 'open'});
...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.