This repository was archived by the owner on Apr 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27.4k
Adding ng-jq functionality, the ability to choose your angular.element l... #10750
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -767,6 +767,36 @@ function equals(o1, o2) { | |
return false; | ||
} | ||
|
||
/** | ||
* @ngdoc directive | ||
* @name ng.directive:ngJq | ||
* | ||
* @element html | ||
* @param {string} (optional) the name of the library available under `window` to be used for angular.element | ||
* | ||
* @description | ||
* | ||
* Use this directive to force the angular.element library. This should be used to force | ||
* either jqLite by leaving ng-jq blank or setting the name of the jquery variable under window | ||
* (eg. jQuery). | ||
* | ||
* This directive is global for the whole of the angular library, hence the directive can only | ||
* be added to the top-most HTML element. | ||
* | ||
*/ | ||
var jq = function () { | ||
if (isDefined(jq.name_)) return jq.name_; | ||
|
||
var el = document.querySelector('[ng-jq]') || document.querySelector('[data-ng-jq]'); | ||
var name = undefined; | ||
|
||
if (el) { | ||
name = el.getAttribute('ng-jq') || el.getAttribute('data-ng-jq') || ''; | ||
} | ||
|
||
return (jq.name_ = name); | ||
}; | ||
|
||
|
||
function concat(array1, array2, index) { | ||
return array1.concat(slice.call(array2, index)); | ||
|
@@ -1147,7 +1177,7 @@ function snake_case(name, separator){ | |
|
||
function bindJQuery() { | ||
// bind to jQuery if present; | ||
jQuery = window.jQuery; | ||
jQuery = jq() ? window[jq()] : window.jQuery; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this will not do what you are expecting as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. BTW, please do not call There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @lgalfaso hm, guess I need to change my unit tests then. Thanks for the heads up. Will change right now. |
||
// reset to jQuery or default to us. | ||
if (jQuery) { | ||
jqLite = jQuery; | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should follow the same mechanism that we have for
ng-app
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lgalfaso this branch looks like it's very old, a lot of things are missing. In current branch, it's possible to use
getNgAttribute(rootElement, 'jq')
to check for these bootstrap parametersThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you are right, the branch is really old
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lgalfaso I'm going on @mzgol suggestions on how to implement this, which was based on ng-csp since angular.element is a global variable, unlike ng-app which you can have multiple in a page.
As for the branch itself, this was the latest that I could get from github, fetching the latest from upstream and making sure that my master has the same last commit than the angular one. If there's any branch 'weirdness', I can't comment why that would be.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parent of 9b7b0fc is 28fe446
28fe446 was committed on Oct 6, 2013
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Crap. That's weird. Something must of messed up somewhere.
Let me add some of your suggestions and I'll create a new pull request based on the right parent.
Cheers.