lemonadejs
Advanced tools
Comparing version 2.0.2 to 2.0.3
/** | ||
* Lemonadejs v2.0.1 | ||
* Lemonadejs v2.0.3 | ||
* | ||
@@ -107,5 +107,5 @@ * Website: https://lemonadejs.net | ||
// Onchange | ||
if (typeof(this.onchange) == 'function') { | ||
this.onchange.call(this.self, property, t); | ||
// Onchange // DOCS update | ||
if (typeof(this.self.onchange) == 'function') { | ||
this.self.onchange.call(this, property, t, this.self); | ||
} | ||
@@ -145,2 +145,3 @@ } | ||
if (tokens.length) { | ||
var self = this.self; | ||
// Value | ||
@@ -259,2 +260,5 @@ var value = eval(res.v) || ''; | ||
element.self = {}; | ||
element.self.template = element.innerHTML; | ||
// Remove the template | ||
element.innerHTML = ''; | ||
} | ||
@@ -295,3 +299,3 @@ } | ||
// Make it available to the self | ||
this.self[prop] = element; | ||
this.self[prop] = element.self ? element.self : element; | ||
// Remove attribute | ||
@@ -371,4 +375,3 @@ element.removeAttribute(k[i]); | ||
// Add handler to the queue | ||
//this.queue.push(Function('f','e','s', 'lemonade.render(f, e, s)').bind(r, f, r, s)); | ||
L.render(f, r, s); | ||
this.queue.push(Function('f','e','s', 'lemonade.render(f, e, s)').bind(r, f, r, s)); | ||
} else { | ||
@@ -396,4 +399,4 @@ // Generate loop | ||
if (data.length) { | ||
for (var i = 0; i < data.length; i++) { | ||
let o = data[i].__el; | ||
for (let i = 0; i < data.length; i++) { | ||
let o = data[i].el; | ||
if (! o) { | ||
@@ -403,3 +406,3 @@ // Create element | ||
// Create propety | ||
Object.defineProperty(data[i], '__el', { | ||
Object.defineProperty(data[i], 'el', { | ||
get: function() { | ||
@@ -410,14 +413,21 @@ // Keep the reference to the DOM | ||
}); | ||
// Parent | ||
Object.defineProperty(data[i], 'parent', { | ||
get: function() { | ||
// Keep the reference to the parent | ||
return data; | ||
} | ||
}); | ||
} | ||
d.push(o); | ||
} | ||
// Remove all DOM | ||
while (r.firstChild) { | ||
r.firstChild.remove(); | ||
} | ||
// Insert necessary DOM | ||
while (t = d.shift()) { | ||
r.appendChild(t); | ||
} | ||
} | ||
// Remove all DOM | ||
while (r.firstChild) { | ||
r.firstChild.remove(); | ||
} | ||
// Insert necessary DOM | ||
while (t = d.shift()) { | ||
r.appendChild(t); | ||
} | ||
} | ||
@@ -485,8 +495,8 @@ | ||
// Create the root element | ||
var div = document.createElement('div'); | ||
var el = document.createElement('div'); | ||
// Get the DOM content | ||
div.innerHTML = t.trim(); | ||
el.innerHTML = t.trim(); | ||
// Already single DOM, do not need a container | ||
if (div.childNodes.length == 1) { | ||
div = div.childNodes[0]; | ||
if (el.childNodes.length == 1) { | ||
el = el.childNodes[0]; | ||
} else { | ||
@@ -496,12 +506,12 @@ console.error('The template should have a single root'); | ||
} else { | ||
var div = t; | ||
var el = t; | ||
} | ||
// Parse the content | ||
parse.call(lemon, div); | ||
parse.call(lemon, el); | ||
// Make lemon object available though the DOM is there a better way | ||
div.lemon = lemon; | ||
el.lemon = lemon; | ||
return div; | ||
return el; | ||
} | ||
@@ -508,0 +518,0 @@ |
@@ -17,3 +17,3 @@ { | ||
"main": "dist/lemonade.js", | ||
"version": "2.0.2" | ||
"version": "2.0.3" | ||
} |
21844
524