Dont store empty classes or events if they are null upon change.
This commit is contained in:
parent
bfca6d48e6
commit
4e53913331
@ -276,9 +276,14 @@ class IgniteTemplate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Remove the old value
|
||||||
this.classes = this.classes.filter(cl => cl != oldValue && cl != newValue);
|
this.classes = this.classes.filter(cl => cl != oldValue && cl != newValue);
|
||||||
|
|
||||||
|
//Add the new value if its valid.
|
||||||
|
if (newValue !== null && newValue !== undefined) {
|
||||||
this.classes.push(newValue);
|
this.classes.push(newValue);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a attribute on this template was changed and needs to be updated
|
* Called when a attribute on this template was changed and needs to be updated
|
||||||
@ -353,9 +358,13 @@ class IgniteTemplate {
|
|||||||
|
|
||||||
//Remove the old value from the events
|
//Remove the old value from the events
|
||||||
this.events[eventName] = this.events[eventName].filter(ev => ev != oldValue);
|
this.events[eventName] = this.events[eventName].filter(ev => ev != oldValue);
|
||||||
|
|
||||||
|
//Add the new value if it's needed
|
||||||
|
if (newValue !== null && newValue !== undefined) {
|
||||||
this.events[eventName].push(newValue);
|
this.events[eventName].push(newValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class div extends IgniteTemplate {
|
class div extends IgniteTemplate {
|
||||||
|
15
src/sheet.js
15
src/sheet.js
@ -12,7 +12,8 @@ class Sheet extends IgniteElement {
|
|||||||
items: ["1", "2"],
|
items: ["1", "2"],
|
||||||
href: "www.google.com",
|
href: "www.google.com",
|
||||||
name: "default content",
|
name: "default content",
|
||||||
linkClick: this.onClick
|
linkClick: this.onClick1,
|
||||||
|
linkClick2: this.onClick2
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -29,15 +30,17 @@ class Sheet extends IgniteElement {
|
|||||||
new html("<h3>---- begin sheet's slot ----<h3>"),
|
new html("<h3>---- begin sheet's slot ----<h3>"),
|
||||||
new slot(this),
|
new slot(this),
|
||||||
new html("<h3>---- end of slot ----</h3>"),
|
new html("<h3>---- end of slot ----</h3>"),
|
||||||
new a("I go nowhere, but you can click me ;)").on("click", this.linkClick)
|
new a("I go nowhere, but you can click me ;)").on("click", this.linkClick).on("click", this.linkClick2)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
onClick(event) {
|
onClick1(event) {
|
||||||
console.log("Element was clicked!");
|
console.log("Element was clicked 1!");
|
||||||
console.log("Event:");
|
}
|
||||||
console.log(event);
|
|
||||||
|
onClick2(event) {
|
||||||
|
console.log("Element was clicked 2!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user