diff options
| author | Igor Minar | 2011-07-12 00:44:18 -0700 | 
|---|---|---|
| committer | Igor Minar | 2011-07-13 16:21:08 -0700 | 
| commit | 47efe44a1d8c9a40526a610b5ee31c44288adee0 (patch) | |
| tree | 26c45bc1fb7f11307e5038a6e45d400bff3d86bd /src | |
| parent | c52e749a6eaec80a1229c59d7f938ec729f5ec8c (diff) | |
| download | angular.js-47efe44a1d8c9a40526a610b5ee31c44288adee0.tar.bz2 | |
fix($browser.addJs): make addJs jQuery compatible
Change addJs implementation to avoid use of jQuery because of issues
that affect angular-ie-compat.js. See inlined comment for more info.
Diffstat (limited to 'src')
| -rw-r--r-- | src/Browser.js | 24 | 
1 files changed, 17 insertions, 7 deletions
| diff --git a/src/Browser.js b/src/Browser.js index d6b2b8d0..535396bd 100644 --- a/src/Browser.js +++ b/src/Browser.js @@ -416,16 +416,26 @@ function Browser(window, document, body, XHR, $log) {     * @methodOf angular.service.$browser     *     * @param {string} url Url to js file -   * @param {string=} dom_id Optional id for the script tag +   * @param {string=} domId Optional id for the script tag     *     * @description     * Adds a script tag to the head.     */ -  self.addJs = function(url, dom_id) { -    var script = jqLite(rawDocument.createElement('script')); -    script.attr('type', 'text/javascript'); -    script.attr('src', url); -    if (dom_id) script.attr('id', dom_id); -    body.append(script); +  self.addJs = function(url, domId) { +    // we can't use jQuery/jqLite here because jQuery does crazy shit with script elements, e.g.: +    // - fetches local scripts via XHR and evals them +    // - adds and immediately removes script elements from the document +    // +    // We need addJs to be able to add angular-ie-compat.js which is very special and must remain +    // part of the DOM so that the embedded images can reference it. jQuery's append implementation +    // (v1.4.2) fubars it. +    var script = rawDocument.createElement('script'); + +    script.type = 'text/javascript'; +    script.src = url; +    if (domId) script.id = domId; +    body[0].appendChild(script); + +    return script;    };  } | 
