Skip to content

Instantly share code, notes, and snippets.

new Vue({
el: '#app',
data: {
message: 'Hello Vue.js!'
}
})
@hectorlorenzo
hectorlorenzo / vue_1_1.js
Last active August 3, 2016 09:32
Vue.js Instance 1:1
function Vue (options) {
this._init(options)
}
// install internals
initMixin(Vue)
stateMixin(Vue)
eventsMixin(Vue)
lifecycleMixin(Vue)
miscMixin(Vue)
import initMixin from './internal/init'
/* ... */
function Vue (options) {
this._init(options)
}
/* ... */
class CustomHeading extends HTMLElement {
constructor () {}
}
customElements.define('custom-heading', CustomHeading)
Vue.component('my-component', {
template: '<div>A custom component!</div>'
})
const customHeading = document.createElement('custom-heading')
document.body.appendChild(customHeading)
const elemClass = class extends HTMLElement {
constructor() {
super()
}
connectedCallback () {
const o = this
const data = o.options.data
Object.keys(data).forEach((key) => {
Object.defineProperty(o, key, {
const elemClass = class extends HTMLElement {
constructor() {
super()
}
attributeChangedCallback (name, oldValue, newValue) {
const o = this
const options = o.options
options.watch[name].call(o, oldValue, newValue)
}
const elemClass = class extends HTMLElement {
constructor() {
super()
}
static get observedAttributes () {
return Object.keys(this.options.data)
}
}
@hectorlorenzo
hectorlorenzo / aocd1.js
Created December 1, 2017 17:58
Advent of code day 1
function sumConsecutive (number) {
var arrayOfNumbers = number.split('')
var sum = 0
var currentNumber = null
var nextNumber = null
var arrayLength = arrayOfNumbers.length
for (var i = arrayLength - 1; i >= 0; i--) {
currentNumber = arrayOfNumbers[i]