Skip to content

Instantly share code, notes, and snippets.

@wuxiaoying
Created February 6, 2015 01:30
Show Gist options
  • Save wuxiaoying/4dca547970982cb60bda to your computer and use it in GitHub Desktop.
Save wuxiaoying/4dca547970982cb60bda to your computer and use it in GitHub Desktop.
// This is in PolymerExpressions prototype
prepareBinding: function(pathString, name, node) {
var path = Path.get(pathString);
if (!isLiteralExpression(pathString) && path.valid) {
if (path.length == 1) {
return function(model, node, oneTime) {
if (oneTime)
return path.getValueFrom(model);
var scope = findScope(model, path[0]);
return new PathObserver(scope, path);
};
}
return; // bail out early if pathString is simple path.
}
return prepareBinding(pathString, name, node, this);
},
// You can see that it passes itself into prepareBinding function as filterRegistry
function prepareBinding(expressionText, name, node, filterRegistry) {
var expression;
try {
expression = getExpression(expressionText);
if (expression.scopeIdent &&
(node.nodeType !== Node.ELEMENT_NODE ||
node.tagName !== 'TEMPLATE' ||
(name !== 'bind' && name !== 'repeat'))) {
throw Error('as and in can only be used within <template bind/repeat>');
}
} catch (ex) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment