add eslint

This commit is contained in:
John Shaver 2019-03-25 20:24:57 -07:00
parent 804022da59
commit 3df69322c9
3 changed files with 2 additions and 23 deletions

View File

@ -4,7 +4,7 @@ import getId from "./id.js";
export function hookComponentFactory(name, propNames, hookRender) { export function hookComponentFactory(name, propNames, hookRender) {
class ComponentClass extends HTMLElement { class ComponentClass extends HTMLElement {
constructor (...args) { constructor (...args) {
super(); super(...args);
this.attachShadow({mode: 'open'}); this.attachShadow({mode: 'open'});
this.identifier = getId(name); this.identifier = getId(name);
this.domRender = hookRender.bind(this); this.domRender = hookRender.bind(this);
@ -22,12 +22,10 @@ export function hookComponentFactory(name, propNames, hookRender) {
this.render(this.parseAttributes()) this.render(this.parseAttributes())
} }
parseAttributes() { parseAttributes() {
console.log(this);
let attr = {}; let attr = {};
for(let i = 0; i < this.attributes.length; ++i) { for(let i = 0; i < this.attributes.length; ++i) {
attr[this.attributes[i].name] = this.getAttribute(this.attributes[i].name); attr[this.attributes[i].name] = this.getAttribute(this.attributes[i].name);
} }
console.log("Parse attributes: ", attr);
return attr; return attr;
} }
} }

View File

@ -3,7 +3,7 @@ import getId from "./id.js";
export function pureComponentFactory (name, propNames, functionalRender) { export function pureComponentFactory (name, propNames, functionalRender) {
class ComponentClass extends HTMLElement { class ComponentClass extends HTMLElement {
constructor (...args) { constructor (...args) {
super(); super(...args);
this.attachShadow({mode: 'open'}); this.attachShadow({mode: 'open'});
this.identifier = getId(name); this.identifier = getId(name);
return; return;
@ -23,12 +23,10 @@ export function pureComponentFactory (name, propNames, functionalRender) {
this.render(this.parseAttributes()) this.render(this.parseAttributes())
} }
parseAttributes() { parseAttributes() {
console.log(this);
let attr = {}; let attr = {};
for(let i = 0; i < this.attributes.length; ++i) { for(let i = 0; i < this.attributes.length; ++i) {
attr[this.attributes[i].name] = this.getAttribute(this.attributes[i].name); attr[this.attributes[i].name] = this.getAttribute(this.attributes[i].name);
} }
console.log("Parse attributes: ", attr);
return attr; return attr;
} }

17
test.js
View File

@ -1,17 +0,0 @@
let count = pureComponentFactory(
"count-ele",
({count}) => {
console.log("RENDERING COUNT: ", count);
return `<div> <label> count: ${count}</label></div>`
}
);
var buttonPress = function() {
let count = document.querySelector("#count");
let oldValue = parseInt(count.getAttribute('count'))
let newValue = oldValue + 1;
console.log(`OldValue: ${oldValue} NewValue: ${newValue}`);
count.setAttribute('count', newValue.toString());
};