Comparing version 0.11.0 to 0.12.0
@@ -44,4 +44,2 @@ var HybridMap = require('hybrid-map').HybridMap, | ||
function setBinding(path, details){ | ||
details.captureBubbling = paths.isBubbleCapture(path); | ||
// Handle wildcards | ||
@@ -112,4 +110,3 @@ if(path.indexOf(pathConstants.wildcard)>=0){ | ||
var wildcardParts = paths.toParts(paths.resolve('[/]', parentPath, binding)), | ||
targetParts = paths.toParts(target), | ||
wildcardMatchFail; | ||
targetParts = paths.toParts(target); | ||
@@ -121,13 +118,17 @@ for(var i = 0; i < wildcardParts.length; i++) { | ||
}else if (pathPart !== targetParts[i]){ | ||
return; | ||
return false; | ||
} | ||
} | ||
if(!wildcardMatchFail){ | ||
return paths.create(wildcardParts); | ||
} | ||
return paths.create(wildcardParts); | ||
} | ||
} | ||
function triggerPath(path, target, type){ | ||
function createGetValue(expression, parentPath){ | ||
return function(scope, returnAsTokens){ | ||
return modelGet(expression, parentPath, scope, returnAsTokens); | ||
} | ||
} | ||
function triggerPath(path, target, captureType){ | ||
var targetReference = get(path, modelBindings), | ||
@@ -142,3 +143,5 @@ referenceDetails = modelBindingDetails.get(targetReference); | ||
if(!wildcardPath && type === 'bubble' && !details.captureBubbling){ | ||
// binding had wildcards but | ||
// did not match the current target | ||
if(wildcardPath === false){ | ||
continue; | ||
@@ -150,6 +153,4 @@ } | ||
binding: wildcardPath || details.binding, | ||
type: type, | ||
getValue: function(scope, returnAsTokens){ | ||
return modelGet(wildcardPath || details.binding, details.parentPath, scope, returnAsTokens); | ||
} | ||
captureType: captureType, | ||
getValue: createGetValue(wildcardPath || details.binding, details.parentPath) | ||
}); | ||
@@ -159,3 +160,3 @@ }; | ||
if(!type || type === 'sink'){ | ||
if(captureType === 'target' || captureType === 'sink'){ | ||
for(var key in targetReference){ | ||
@@ -167,3 +168,3 @@ triggerPath(paths.append(path, key), path, 'sink'); | ||
function trigger(path, type){ | ||
function trigger(path){ | ||
// resolve path to root | ||
@@ -177,18 +178,14 @@ path = paths.resolve(paths.createRoot(), path); | ||
if(!type){ | ||
for(var i = 0; i < pathParts.length; i++){ | ||
var bubbleType; | ||
for(var i = 0; i < pathParts.length; i++){ | ||
var captureType = 'bubble'; | ||
currentBubblePath = paths.append(currentBubblePath, pathParts[i]); | ||
currentBubblePath = paths.append(currentBubblePath, pathParts[i]); | ||
if(i === pathParts.length -2 && !isNaN(pathParts[i+1])){ | ||
bubbleType = 'arrayItem'; | ||
}else{ | ||
bubbleType = 'bubble'; | ||
} | ||
triggerPath(currentBubblePath, path, bubbleType); | ||
if(i === pathParts.length -2 && !isNaN(pathParts[i+1])){ | ||
captureType = 'arrayItem'; | ||
}else if(i === pathParts.length -1){ | ||
captureType = 'target'; | ||
} | ||
triggerPath(currentBubblePath, path, captureType); | ||
} | ||
triggerPath(path, path, type); | ||
} | ||
@@ -195,0 +192,0 @@ |
@@ -5,3 +5,3 @@ { | ||
"author": "Kory Nunn <knunn187@gmail.com>", | ||
"version": "0.11.0", | ||
"version": "0.12.0", | ||
"main": "gedi.js", | ||
@@ -8,0 +8,0 @@ "dependencies": { |
42663
890