Comparing version 1.0.1 to 1.0.2
@@ -8,26 +8,28 @@ (function() { | ||
"if": { | ||
"#": function(el, path) { | ||
var comment, parent; | ||
comment = document.createComment("#if"); | ||
parent = null; | ||
this.__deferredStructure.push(function() { | ||
var value; | ||
parent = el.parentNode; | ||
value = this.$path.toValue({ | ||
path: path | ||
}).value; | ||
if (!value) { | ||
return parent.replaceChild(comment, el); | ||
"#": function(el, path, mods) { | ||
return this.$structure.beforeInsert.push(function(structure) { | ||
var comment, index, parent, value; | ||
comment = document.createComment("#if"); | ||
parent = el.parentNode || this; | ||
if (parent === this) { | ||
value = this.$path.toValue({ | ||
path: path | ||
}).value; | ||
if (!value) { | ||
index = structure.indexOf(el); | ||
structure[index] = comment; | ||
} | ||
} | ||
}); | ||
return this.$watch.path({ | ||
path: path, | ||
initial: false, | ||
cbs: function(value) { | ||
if (value) { | ||
return parent.replaceChild(el, comment); | ||
} else { | ||
return parent.replaceChild(comment, el); | ||
return this.$watch.path({ | ||
path: path, | ||
cbs: function(value, oldVal) { | ||
if (value !== oldVal) { | ||
if (value && comment.parentNode === parent) { | ||
return parent.replaceChild(el, comment); | ||
} else if (!value && el.parentNode === parent) { | ||
return parent.replaceChild(comment, el); | ||
} | ||
} | ||
} | ||
} | ||
}); | ||
}); | ||
@@ -34,0 +36,0 @@ } |
@@ -72,3 +72,3 @@ (function() { | ||
window.__ceriDeps = tmp; | ||
if (o.oldValue !== o.value) { | ||
if (!isObject(o.value) && o.oldValue !== o.value) { | ||
ref1 = o.cDeps; | ||
@@ -104,3 +104,3 @@ for (i = 0, len = ref1.length; i < len; i++) { | ||
k = ref1[i]; | ||
if (k.indexOf(o.path) > -1) { | ||
if (k.indexOf(o.path) > -1 && k !== o.path) { | ||
o.parent[o.name]; | ||
@@ -107,0 +107,0 @@ break; |
@@ -18,2 +18,3 @@ (function() { | ||
], | ||
_rebind: "$structure", | ||
mixins: [require("./path"), require("./watch"), require("./$setAttribute")], | ||
@@ -41,4 +42,8 @@ _attrLookup: { | ||
methods: { | ||
"$structure": { | ||
beforeInsert: [], | ||
afterInsert: [] | ||
}, | ||
el: function(name, options, children) { | ||
var cb, child, el, i, len, lookupObj, mods, ref1, type, types, value; | ||
var capture, cb, child, el, fn, i, len, lookupObj, mods, ref1, type, types, value; | ||
if (((ref1 = this._elLookup) != null ? ref1[name] : void 0) != null) { | ||
@@ -85,35 +90,33 @@ el = this._elLookup[name].call(this, name); | ||
case "@": | ||
this.__deferredStructure.push((function(el, name, value, mods) { | ||
var capture, fn; | ||
if (isString(value)) { | ||
value = this.$path.toValue({ | ||
path: value | ||
}).value; | ||
} | ||
if (mods != null) { | ||
capture = mods.capture; | ||
fn = function(e) { | ||
if (mods.self && e.target !== el) { | ||
return; | ||
} | ||
if (mods.notPrevented && e.defaultPrevented) { | ||
return; | ||
} | ||
value.apply(this, arguments); | ||
if (mods.prevent) { | ||
e.preventDefault(); | ||
} | ||
if (mods.stop) { | ||
e.stopPropagation(); | ||
} | ||
if (mods.once) { | ||
return el.removeEventListener(name, fn); | ||
} | ||
}; | ||
} else { | ||
fn = value; | ||
} | ||
fn = fn.bind(this); | ||
return el.addEventListener(name, fn, capture); | ||
}).bind(this, el, name, value, mods)); | ||
if (isString(value)) { | ||
value = this.$path.toValue({ | ||
path: value | ||
}).value; | ||
} | ||
if (mods != null) { | ||
capture = mods.capture; | ||
fn = function(e) { | ||
if (mods.self && e.target !== el) { | ||
return; | ||
} | ||
if (mods.notPrevented && e.defaultPrevented) { | ||
return; | ||
} | ||
value.apply(this, arguments); | ||
if (mods.prevent) { | ||
e.preventDefault(); | ||
} | ||
if (mods.stop) { | ||
e.stopPropagation(); | ||
} | ||
if (mods.once) { | ||
return el.removeEventListener(name, fn); | ||
} | ||
}; | ||
} else { | ||
capture = null; | ||
fn = value; | ||
} | ||
fn = fn.bind(this); | ||
el.addEventListener(name, fn, capture); | ||
break; | ||
@@ -171,22 +174,26 @@ case "~": | ||
connectedCallback: function() { | ||
var child, el, fn, i, j, k, len, len1, len2, ref1, ref2, ref3, ref4, results, slot, structure; | ||
var child, el, fn, i, j, k, l, len, len1, len2, len3, ref1, ref2, ref3, ref4, ref5, results, slot, structure; | ||
if (this._isFirstConnect && (this.structure != null)) { | ||
this.__deferredStructure = []; | ||
structure = arrayize(this.structure()); | ||
ref1 = this.children; | ||
ref1 = this.$structure.beforeInsert; | ||
for (i = 0, len = ref1.length; i < len; i++) { | ||
child = ref1[i]; | ||
fn = ref1[i]; | ||
fn.call(this, structure); | ||
} | ||
ref2 = this.children; | ||
for (j = 0, len1 = ref2.length; j < len1; j++) { | ||
child = ref2[j]; | ||
slot = child.getAttribute("slot"); | ||
if (slot != null) { | ||
if ((ref2 = this._slots[slot]) != null) { | ||
ref2.appendChild(slot); | ||
if ((ref3 = this._slots[slot]) != null) { | ||
ref3.appendChild(slot); | ||
} | ||
} else { | ||
if ((ref3 = this._slots["default"]) != null) { | ||
ref3.appendChild(child); | ||
if ((ref4 = this._slots["default"]) != null) { | ||
ref4.appendChild(child); | ||
} | ||
} | ||
} | ||
for (j = 0, len1 = structure.length; j < len1; j++) { | ||
el = structure[j]; | ||
for (k = 0, len2 = structure.length; k < len2; k++) { | ||
el = structure[k]; | ||
if (isString(el)) { | ||
@@ -198,6 +205,6 @@ this._slots[el] = this; | ||
} | ||
ref4 = this.__deferredStructure; | ||
ref5 = this.$structure.afterInsert; | ||
results = []; | ||
for (k = 0, len2 = ref4.length; k < len2; k++) { | ||
fn = ref4[k]; | ||
for (l = 0, len3 = ref5.length; l < len3; l++) { | ||
fn = ref5[l]; | ||
results.push(fn.call(this)); | ||
@@ -204,0 +211,0 @@ } |
@@ -199,3 +199,5 @@ (function() { | ||
if (o.value != null) { | ||
o.parent[o.name] = o.value; | ||
if (o.parent[o.name] !== o.value) { | ||
o.parent[o.name] = o.value; | ||
} | ||
} else if (o.initial) { | ||
@@ -202,0 +204,0 @@ val = o.parent[o.name]; |
{ | ||
"name": "ceri", | ||
"description": "Custom Elements enRIched", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"homepage": "https://github.com/cerijs/", | ||
@@ -6,0 +6,0 @@ "author": { |
66366
24
1697