aboutsummaryrefslogtreecommitdiffstats
path: root/src/Compiler.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/Compiler.js')
-rw-r--r--src/Compiler.js12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/Compiler.js b/src/Compiler.js
index 4f30521b..923f7b2f 100644
--- a/src/Compiler.js
+++ b/src/Compiler.js
@@ -73,11 +73,12 @@ function eachNode(element, fn){
}
function eachAttribute(element, fn){
- var i, attrs = element[0].attributes || [], size = attrs.length, chld, attr;
+ var i, attrs = element[0].attributes || [], size = attrs.length, chld, attr, attrValue = {};
for (i = 0; i < size; i++) {
var attr = attrs[i];
- fn(attr.name, attr.value);
+ attrValue[attr.name] = attr.value;
}
+ foreach(attrValue, fn);
}
function Compiler(textMarkup, attrMarkup, directives, widgets){
@@ -92,12 +93,15 @@ Compiler.prototype = {
rawElement = jqLite(rawElement);
var template = this.templatize(rawElement) || new Template();
return function(element, parentScope){
+ parentScope = parentScope || {};
var scope = createScope(parentScope);
+ parentScope.$root = parentScope.$root || scope;
return extend(scope, {
$element:element,
$init: function() {
template.init(element, scope);
scope.$eval();
+ return scope;
}
});
};
@@ -132,12 +136,12 @@ Compiler.prototype = {
});
// Process attributes/directives
- eachAttribute(element, function(name, value){
+ eachAttribute(element, function(value, name){
foreach(self.attrMarkup, function(markup){
markup.call(selfApi, value, name, element);
});
});
- eachAttribute(element, function(name, value){
+ eachAttribute(element, function(value, name){
var directive = directives[name];
if (!exclusive && directive) {
if (directive.exclusive) {