Last active
April 27, 2018 19:13
-
-
Save jasonmit/9fc5d75efa52252fc95098a407c9aa7f to your computer and use it in GitHub Desktop.
custom element test
This file contains hidden or 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
import Ember from 'ember'; | |
import '../custom-element'; | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle', | |
count: 0, | |
actions: { | |
handleCounterClick() { | |
this.incrementProperty('count'); | |
} | |
} | |
}); |
This file contains hidden or 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
/* javascript things */ | |
eval(` | |
class ClickCounter extends HTMLElement { | |
constructor() { | |
super(); | |
let shadow = this.attachShadow({ mode: 'open' }); | |
this.setup(shadow); | |
} | |
handleButtonClick() { | |
let event = new CustomEvent('customEventName', { | |
bubbles: true, | |
cancelable: false | |
}); | |
this.dispatchEvent(event); | |
} | |
setup(shadow) { | |
let btn = document.createElement('button'); | |
btn.addEventListener('click', this.handleButtonClick.bind(this), false, false); | |
btn.textContent = 'Submit'; | |
shadow.appendChild(btn); | |
} | |
} | |
// Define the new element | |
customElements.define('click-counter', ClickCounter); | |
`); |
This file contains hidden or 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
{ | |
"version": "0.13.1", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "2.16.2", | |
"ember-template-compiler": "2.16.2", | |
"ember-testing": "2.16.2" | |
}, | |
"addons": { | |
"ember-data": "2.16.3" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment