diff options
| author | Misko Hevery | 2011-02-07 13:28:42 -0800 | 
|---|---|---|
| committer | Misko Hevery | 2011-02-16 00:48:22 -0500 | 
| commit | 0a5c00abf8664fdbdc5d16b13adb1989b4531cdf (patch) | |
| tree | 42d9426de8aa7917ba2dc127ee35dbc5890d7877 /src | |
| parent | a004d487c4bb48b2bec19b60bc5ddc5244029be5 (diff) | |
| download | angular.js-0a5c00abf8664fdbdc5d16b13adb1989b4531cdf.tar.bz2 | |
Add public API to retrieve scope from element.
Diffstat (limited to 'src')
| -rw-r--r-- | src/Angular.js | 9 | ||||
| -rw-r--r-- | src/Compiler.js | 12 | ||||
| -rw-r--r-- | src/jqLite.js | 9 | ||||
| -rw-r--r-- | src/widgets.js | 2 | 
4 files changed, 18 insertions, 14 deletions
| diff --git a/src/Angular.js b/src/Angular.js index b856aa24..9a1ab4a2 100644 --- a/src/Angular.js +++ b/src/Angular.js @@ -1032,5 +1032,12 @@ function angularJsConfig(document, config) {  function bindJQuery(){    // bind to jQuery if present;    jQuery = window.jQuery; -  angular.element = jqLite = jQuery || jqLiteWrap; +  // reset to jQuery or default to us. +  if (window.jQuery) { +    jqLite = window.jQuery; +    jqLite.fn.scope = JQLite.prototype.scope; +  } else { +    jqLite = jqLiteWrap; +  } +  angular.element = jqLite;  } diff --git a/src/Compiler.js b/src/Compiler.js index 472ec625..d1505404 100644 --- a/src/Compiler.js +++ b/src/Compiler.js @@ -69,18 +69,6 @@ Template.prototype = {    }  }; -/* - * Function walks up the element chain looking for the scope associated with the give element. - */ -function retrieveScope(element) { -  var scope; -  element = jqLite(element); -  while (element && element.length && !(scope = element.data($$scope))) { -    element = element.parent(); -  } -  return scope; -} -  ///////////////////////////////////  //Compiler  ////////////////////////////////// diff --git a/src/jqLite.js b/src/jqLite.js index ad7734c9..206c1d70 100644 --- a/src/jqLite.js +++ b/src/jqLite.js @@ -87,6 +87,15 @@ JQLite.prototype = {      })(this[0]);    }, +  scope: function() { +    var scope, element = this; +    while (element && element.length && !(scope = element.data($$scope))) { +      element = element.parent(); +    } +    return scope; +  }, + +    ready: function(fn) {      var fired = false; diff --git a/src/widgets.js b/src/widgets.js index 461684ac..f8efae60 100644 --- a/src/widgets.js +++ b/src/widgets.js @@ -561,7 +561,7 @@ angularWidget('option', function(){    return function(option) {      var select = option.parent();      var isMultiple = select[0].type == 'select-multiple'; -    var scope = retrieveScope(select); +    var scope = select.scope();      var model = modelAccessor(scope, select);      //if parent select doesn't have a name, don't bother doing anything any more | 
