-
Notifications
You must be signed in to change notification settings - Fork 27.4k
Adding ng-jq functionality, the ability to force jqLite or any other lib... #10761
Conversation
@mboudreau Thanks, I'll review it later today. Note for the future - never commit anything to the master branch, this is probably the source of your problems. master should be used exclusively to pull from the upstream master so that you can easily have the same master locally as the latest master in the Angular repository. Your changes should be made on a different branch that you can then easily rebase on top of master. Another thing: if sth goes wrong it's not necessary to open a new PR; it's enough if you amend the commit, introduce changes, rebase on top of latest master and do "git push --force". GitHub will pick it up as long as the branch name doesn't change. You can read this guide: http://contribute.jquery.org/commits-and-pull-requests/ |
@mzgol Thanks for the tips. I already knew about them, I just didn't want to mess up things for the Angular team and I figured a redo would of been simpler. Maybe not. Either way, it's done now :P @petebacondarwin Is there anything else you want me to do? Like add that public api? |
@mboudreau Fire |
* (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. |
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.
This is not true as you're catching ng-jq
anywhere in the document. I'd rather copy the text from ngCsp.js
:
"put the ngJq
directive on the root element of the application or on the angular.js
script tag, whichever appears first in the html document."
so that it's advised to put it there but not claim it won't work otherwise.
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.
+1
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.
@mboudreau If you could rebase your PR over latest master
after introducing remaining changes, that'd be great. It seems you branched at a commit that fails tests so it's impossible for your PR to pass tests because of that. It should be fine on latest master
(am I right, @petebacondarwin?).
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.
I would expect so @mzgol. Thanks for reviewing this one!
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.
@mzgol @petebacondarwin I just tried merging the upstream master to my local without issue, however, the build is still failing even after an npm/bower install/update. Same error as the CI build (unless there's something different on the build server that I'm missing locally):
error: TypeError: Cannot read property '0' of undefined
at _.groupBy.tap.tap.docTypes.directive (/home/michelb/Work/angular.js/docs/config/processors/pages-data.js:65:43)
at Function.tap (/home/michelb/Work/angular.js/node_modules/lodash/dist/lodash.js:6448:7)
at lodash.ctor.(anonymous function) [as tap] (/home/michelb/Work/angular.js/node_modules/lodash/dist/lodash.js:5924:31)
at /home/michelb/Work/angular.js/docs/config/processors/pages-data.js:62:14
at /home/michelb/Work/angular.js/node_modules/lodash/dist/lodash.js:3513:29
at forOwn (/home/michelb/Work/angular.js/node_modules/lodash/dist/lodash.js:2105:15)
at Function.map (/home/michelb/Work/angular.js/node_modules/lodash/dist/lodash.js:3512:9)
at lodash.ctor.(anonymous function) [as map] (/home/michelb/Work/angular.js/node_modules/lodash/dist/lodash.js:5924:31)
at navGroupMappers.api (/home/michelb/Work/angular.js/docs/config/processors/pages-data.js:53:10)
at /home/michelb/Work/angular.js/docs/config/processors/pages-data.js:192:28
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.
Are you sure you're on a latest master
? If you're on Linux/OS X, could you invoke:
git show -s --format=%ci `git merge-base HEAD master` | head
? This should show you a date from today or yesterday; if it's older, it means you didn't rebase over latest changes.
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.
@mzgol 2015-01-21 09:53:33 +1100
is the output.
Everything looks good to me, I got all the changes. Dunno what I'm missing to build...
Apparently, Travis is having issues too, so I don't know what's going on. Weird stale files somewhere?
|
@mboudreau This looks mostly good, only a couple of remarks. 👍 |
@mzgol Added the fixes from your comments. Cheers. |
@mzgol @petebacondarwin Build still failing after merge from upstream. Anyone care to help me debug? I'm trying to understand this document processor code, but there's a lot of abstraction... |
I don't know for sure, but adding |
* @ngdoc directive | ||
* @name ngJq | ||
* | ||
* @element html |
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.
Why specifically html
?
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.
Should be ANY I think
@gkalpak Thanks for that. That indeed fixed it. I also added all prefixes to the directive. Thanks for your direction :) |
@mzgol CI still failing, but not because of my code:
Is there a way to restart the build? I'm fairly sure it's just me being unlucky :P |
*/ | ||
var jq = function() { | ||
if (isDefined(jq.name_)) return jq.name_; | ||
var el; |
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.
Indentation should be 2 spaces (not tabs).
I restarted the flakey build and all is green now. |
@@ -1457,7 +1510,9 @@ function bindJQuery() { | |||
} | |||
|
|||
// bind to jQuery if present; | |||
jQuery = window.jQuery; | |||
var jqName = jq(); | |||
jQuery = jqName != null ? window[jqName] : window.jQuery; |
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.
I've missed it before: an empty ng-jq
attribute should mean "use jqLite" and not "use the native detection algorithm" as it's done now. Otherwise it'll be impossible for people to opt in to jqLite if jQuery is included on the site which is one of the major points of this functionality. :)
Refs the above comment by @gkalpak.
jQuery = window.jQuery; // use default jQuery. | ||
if (isDefined(jqName)) { // `ngJq` present | ||
jQuery = jqName === null ? undefined : window[jqName]; // if empty; use jqLite. if not empty, use jQuery specified by `ngJq`. | ||
} |
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.
Hm...I still see some tabs here 😕
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.
@gkalpak God damnit. Fixed now.
@mboudreau overall looks good, but can you please squash this into one commit? |
…library by name to be used for angular.element fixing linting and jshint comments, as per @mzgol request fixing weird duplication of docs when merging adding other ng prefixes to be added and test to jq(), fixing documentation error by adding @module ng, changing @element to be any removing tabs, again. removing jq._name = undefined; as not useful anymore adding strict equality for tests Adding better description of ng-jq, fixing tabs/spaces changing the logic behind ngJq to be more robust; removing jQuery = window[jqName] for when jqName is empty string replacing tabs for spaces
@lgalfaso Done :) |
landed as 09ee82d |
Woo! Thanks guys! @lgalfaso @gkalpak @mzgol @petebacondarwin |
...rary by name to be used for angular.element
Added unit tests to check that jq function returns the right result, but couldn't test adding a fake jQuery object without failing many other tests. Maybe this is better for e2e tests? I would add some, but couldn't figure out the structure.