diff options
| -rw-r--r-- | src/Browser.js | 4 | ||||
| -rw-r--r-- | src/Compiler.js | 13 | ||||
| -rw-r--r-- | src/services.js | 12 | ||||
| -rw-r--r-- | src/widgets.js | 9 | ||||
| -rwxr-xr-x | test.sh | 4 | ||||
| -rw-r--r-- | test/widgetsSpec.js | 3 | 
6 files changed, 35 insertions, 10 deletions
| diff --git a/src/Browser.js b/src/Browser.js index d2e8608d..6ec083fa 100644 --- a/src/Browser.js +++ b/src/Browser.js @@ -53,6 +53,10 @@ Browser.prototype = {    },    xhr: function(method, url, post, callback){ +    if (isFunction(post)) { +      callback = post; +      post = null; +    }      var xhr = new this.XHR();      xhr.open(method, url, true);      xhr.onreadystatechange = function() { diff --git a/src/Compiler.js b/src/Compiler.js index c77c6b30..c8910c27 100644 --- a/src/Compiler.js +++ b/src/Compiler.js @@ -77,7 +77,18 @@ function Compiler(textMarkup, attrMarkup, directives, widgets){  Compiler.prototype = {    compile: function(rawElement) {      rawElement = jqLite(rawElement); -    var template = this.templatize(rawElement, 0, 0) || new Template(); +    var index = 0, +        template, +        parent = rawElement.parent(); +    if (parent && parent[0]) { +      parent = parent[0]; +      for(var i = 0; i < parent.childNodes.length; i++) { +        if (parent.childNodes[i] == rawElement[0]) { +          index = i; +        } +      } +    } +    template = this.templatize(rawElement, index, 0) || new Template();      return function(element, parentScope){        element = jqLite(element);        var scope = parentScope && parentScope.$eval ? diff --git a/src/services.js b/src/services.js index 16dbcb35..2cf0e4ad 100644 --- a/src/services.js +++ b/src/services.js @@ -192,6 +192,10 @@ angularService('$route', function(location, params){  angularService('$xhr', function($browser){    var self = this;    return function(method, url, post, callback){ +    if (isFunction(post)) { +      callback = post; +      post = null; +    }      if (post && isObject(post)) {        post = toJson(post);      } @@ -213,6 +217,10 @@ angularService('$xhr.bulk', function($xhr){        callbacks = [],        scope = this;    function bulkXHR(method, url, post, callback) { +    if (isFunction(post)) { +      callback = post; +      post = null; +    }      requests.push({method: method, url: url, data:post});      callbacks.push(callback);    } @@ -240,6 +248,10 @@ angularService('$xhr.bulk', function($xhr){  angularService('$xhr.cache', function($xhr){    var inflight = {};    function cache(method, url, post, callback){ +    if (isFunction(post)) { +      callback = post; +      post = null; +    }      if (method == 'GET') {        var data;        if (data = cache.data[url]) { diff --git a/src/widgets.js b/src/widgets.js index 8a816934..2fade3e3 100644 --- a/src/widgets.js +++ b/src/widgets.js @@ -192,22 +192,21 @@ angularWidget('NG:INCLUDE', function(element){        function incrementChange(){ changeCounter++;}        this.$watch(srcExp, incrementChange);        this.$watch(scopeExp, incrementChange); +      scope.$onEval(function(){ +        if (childScope) childScope.$eval(); +      });        this.$watch(function(){return changeCounter;}, function(){          var src = this.$eval(srcExp),          useScope = this.$eval(scopeExp);          if (src) { -          scope.$browser.xhr('GET', src, function(code, response){ +          scope.$xhr.cache('GET', src, function(code, response){              element.html(response);              childScope = useScope || createScope(scope);              compiler.compile(element)(element, childScope);              childScope.$init(); -            scope.$root.$eval();            });          }        }); -      scope.$onEval(function(){ -        if (childScope) childScope.$eval(); -      });      };    }  }); @@ -1,2 +1,2 @@ -# java -jar lib/jstestdriver/JsTestDriver.jar --tests all -java -jar lib/jstestdriver/JsTestDriver.jar --tests all --config jsTestDriver-jquery.conf +java -jar lib/jstestdriver/JsTestDriver.jar --tests all +# java -jar lib/jstestdriver/JsTestDriver.jar --tests all --config jsTestDriver-jquery.conf diff --git a/test/widgetsSpec.js b/test/widgetsSpec.js index b38ca2a1..c9665f1e 100644 --- a/test/widgetsSpec.js +++ b/test/widgetsSpec.js @@ -276,9 +276,8 @@ describe("widget", function(){        scope.childScope = createScope();        scope.childScope.name = 'misko';        scope.url = 'myUrl'; -      scope.$browser.xhr.expect('GET', 'myUrl').respond('{{name}}'); +      scope.$xhr.cache.data.myUrl = {value:'{{name}}'};        scope.$init(); -      scope.$browser.xhr.flush();        expect(element.text()).toEqual('misko');      });    }); | 
