From b628de9758c313b106d22468f4b49bd223698fd5 Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Sat, 20 Feb 2010 17:27:21 -0800 Subject: fix option value bug --- src/Binder.js | 64 +++++++++++++++++++++++++++++++---------------------------- 1 file changed, 34 insertions(+), 30 deletions(-) (limited to 'src') diff --git a/src/Binder.js b/src/Binder.js index 4699a601..9fc32513 100644 --- a/src/Binder.js +++ b/src/Binder.js @@ -48,14 +48,14 @@ Binder.prototype = { }); return params; }, - + parseAnchor: function() { var self = this, url = this.location['get']() || ""; - + var anchorIndex = url.indexOf('#'); if (anchorIndex < 0) return; var anchor = url.substring(anchorIndex + 1); - + var anchorQuery = this.parseQueryString(anchor); foreach(self.anchor, function(newValue, key) { delete self.anchor[key]; @@ -64,12 +64,12 @@ Binder.prototype = { self.anchor[key] = newValue; }); }, - + onUrlChange: function() { this.parseAnchor(); this.updateView(); }, - + updateAnchor: function() { var url = this.location['get']() || ""; var anchorIndex = url.indexOf('#'); @@ -91,7 +91,7 @@ Binder.prototype = { this.location['set'](url); return url; }, - + updateView: function() { var start = new Date().getTime(); var scope = jQuery(this.doc).scope(); @@ -101,7 +101,7 @@ Binder.prototype = { this.updateAnchor(); foreach(this.updateListeners, function(fn) {fn();}); }, - + docFindWithSelf: function(exp){ var doc = jQuery(this.doc); var selection = doc.find(exp); @@ -110,7 +110,7 @@ Binder.prototype = { } return selection; }, - + executeInit: function() { this.docFindWithSelf("[ng-init]").each(function() { var jThis = jQuery(this); @@ -122,7 +122,7 @@ Binder.prototype = { } }); }, - + entity: function (scope) { var self = this; this.docFindWithSelf("[ng-entity]").attr("ng-watch", function() { @@ -136,7 +136,7 @@ Binder.prototype = { } }); }, - + compile: function() { var jNode = jQuery(this.doc); if (this.config['autoSubmit']) { @@ -160,7 +160,7 @@ Binder.prototype = { return false; }); }, - + translateBinding: function(node, parentPath, factories) { var path = parentPath.concat(); var offset = path.pop(); @@ -196,7 +196,7 @@ Binder.prototype = { parent.removeChild(node); } }, - + precompile: function(root) { var factories = []; this.precompileNode(root, [], factories); @@ -217,7 +217,7 @@ Binder.prototype = { } }; }, - + precompileNode: function(node, path, factories) { var nodeType = node.nodeType; if (nodeType == Node.TEXT_NODE) { @@ -226,11 +226,11 @@ Binder.prototype = { } else if (nodeType != Node.ELEMENT_NODE && nodeType != Node.DOCUMENT_NODE) { return; } - + if (!node.getAttribute) return; var nonBindable = node.getAttribute('ng-non-bindable'); if (nonBindable || nonBindable === "") return; - + var attributes = node.attributes; if (attributes) { var bindings = node.getAttribute('ng-bind-attr'); @@ -252,7 +252,7 @@ Binder.prototype = { node.setAttribute("ng-bind-attr", json); } } - + if (!node.getAttribute) log(node); var repeaterExpression = node.getAttribute('ng-repeat'); if (repeaterExpression) { @@ -275,7 +275,7 @@ Binder.prototype = { }}); return; } - + if (node.getAttribute('ng-eval')) factories.push({path:path, fn:this.ng_eval}); if (node.getAttribute('ng-bind')) factories.push({path:path, fn:this.ng_bind}); if (node.getAttribute('ng-bind-attr')) factories.push({path:path, fn:this.ng_bind_attr}); @@ -300,53 +300,57 @@ Binder.prototype = { if (nodeName == 'OPTION') { var html = jQuery('