diff options
| author | Igor Minar | 2011-10-25 08:47:02 -0700 | 
|---|---|---|
| committer | Igor Minar | 2011-10-26 12:57:15 -0700 | 
| commit | d7ba5bc83ba9a8937384ea677331c5156ed6772d (patch) | |
| tree | aef0e0eb9873265d6f1cbe90a6f3da360e8367ca /src/Angular.js | |
| parent | 950d02b4d4b1d574dfbb9bbdd56b8dc430db0a93 (diff) | |
| download | angular.js-d7ba5bc83ba9a8937384ea677331c5156ed6772d.tar.bz2 | |
feat(bootstrap): drop angular.js file name restrictions for autobind
The last script element in the dom is always us if the script that
contains angular is loaded synchronously.
For async loading manual bootstrap needs to be performed.
Close #621
Diffstat (limited to 'src/Angular.js')
| -rw-r--r-- | src/Angular.js | 40 | 
1 files changed, 17 insertions, 23 deletions
diff --git a/src/Angular.js b/src/Angular.js index c5a35e4e..ab031049 100644 --- a/src/Angular.js +++ b/src/Angular.js @@ -116,7 +116,6 @@ var _undefined        = undefined,      angularService    = extensionMap(angular, 'service'),      angularCallbacks  = extensionMap(angular, 'callbacks'),      nodeName_, -    rngScript         = /^(|.*\/)angular(-.*?)?(\.min)?.js(\?[^#]*)?(#(.*))?$/,      uid               = ['0', '0', '0'],      DATE_ISOSTRING_LN = 24; @@ -953,35 +952,30 @@ function angularInit(config, document){    var autobind = config.autobind;    if (autobind) { -    var element = isString(autobind) ? document.getElementById(autobind) : document, -        scope = compile(element)(createScope()), -        $browser = scope.$service('$browser'); - -    if (config.css) -      $browser.addCss(config.base_url + config.css); -    scope.$apply(); +    var element = isString(autobind) ? document.getElementById(autobind) : document; +    compile(element)().$apply();    }  }  function angularJsConfig(document) {    bindJQuery(); -  var scripts = document.getElementsByTagName("script"), +  var scripts = document.getElementsByTagName('script'), +      script = scripts[scripts.length-1], +      scriptSrc = script.src,        config = {}, -      match; -  for(var j = 0; j < scripts.length; j++) { -    match = (scripts[j].src || "").match(rngScript); -    if (match) { -      config.base_url = match[1]; -      extend(config, parseKeyValue(match[6])); -      eachAttribute(jqLite(scripts[j]), function(value, name){ -        if (/^ng:/.exec(name)) { -          name = name.substring(3).replace(/-/g, '_'); -          value = value || true; -          config[name] = value; -        } -      }); +      hashPos; + +  hashPos = scriptSrc.indexOf('#'); +  if (hashPos != -1) extend(config, parseKeyValue(scriptSrc.substr(hashPos+1))); + +  eachAttribute(jqLite(script), function(value, name){ +    if (/^ng:/.exec(name)) { +      name = name.substring(3).replace(/-/g, '_'); +      value = value || true; +      config[name] = value;      } -  } +  }); +    return config;  }  | 
