このコミットが含まれているのは:
John Shaver 2019-03-25 20:24:57 -07:00
コミット 3df69322c9
3個のファイルの変更2行の追加23行の削除

ファイルの表示

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

ファイルの表示

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

17
test.js
ファイルの表示

@ -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());
};