-
Notifications
You must be signed in to change notification settings - Fork 2.3k
feat(rootEl): auto-detect the root element better #3849
Conversation
330ec6f to
a8c4961
Compare
|
I might have a much better idea than this, pending talking with @juliemr later today, so don't both reviewing right now |
a8c4961 to
51624ad
Compare
|
As per talking to @juliemr, this will will not be part of a larger change after all. Please review! 😄 |
731c26e to
5b40ed2
Compare
lib/clientsidescripts.js
Outdated
| * | ||
| * @param {string} ngRepeat The ngRepeat to test | ||
| * @param {string} repeater The repeater to test against | ||
| * @param {boolean} exact If the ngRepeat needs to be more or less exactly the |
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 "more or less"? Just 'exactly'
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.
Well, it removes track by and as and everything after | or =. Is it still exactly the repeater? I don't actually understand ng1 well enough to know which parts of the ng-repeat count.
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.
What about If the ngRepeat expression should exactly match.... it's not 100% precise because of track by but I think it gets the idea across more clearly than "more or less"
juliemr
left a comment
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.
Please add a message to the commit description that users no longer need to specify 'useAllAngular2AppRoots' in the config.
Please add a breaking change section to the commit description explaining the way that this could potentially break stuff (I don't think this will affect very many people at all, but we should have at least some sort of guidance for them on how to debug if it does)
lib/clientsidescripts.js
Outdated
| * falsy, tries a variety of methods to find an injector | ||
| * @param {boolean=} injectorPlease Prioritize finding an injector | ||
| * @return {$$testability?: Testability, $injector?: Injector} Returns what | ||
| * the app hooks it finds |
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 description seems to have gotten a bit mangled.
lib/clientsidescripts.js
Outdated
| } else { | ||
| var $injector = angular.element(el).injector(); | ||
| if ($injector) { | ||
| return {$injector: angular.element(el).injector()}; |
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.
just return {$injector: $injector} should work here, yeah?
lib/clientsidescripts.js
Outdated
| if (!ng12Hybrid && window.getAngularTestability) { | ||
| if (window.angular && !(window.angular.version && | ||
| window.angular.version.major > 1)) { | ||
| // ng1 |
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.
use /** */ for comments in here.
lib/clientsidescripts.js
Outdated
| } | ||
| if (angular.getTestability) { | ||
| angular.getTestability(el).whenStable(callback); | ||
| } else if (window.angular.version == 2) { |
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.
As in other PR, let's change this to be future proof for angular versions > 2
lib/config.ts
Outdated
| * CSS Selector for the element housing the angular app - this defaults to | ||
| * 'body', but is necessary if ng-app is on a descendant of <body>. | ||
| * A CSS selector for the DOM element you want Protractor to hook into your | ||
| * app at. |
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.
Maybe
"A CSS Selector for a DOM element within your Angular application. Protractor will attempt to automatically find your application, but It is necessary to set rootElement in certain cases.
In Angular 1, Protractor will use bootstrapping and then search for body or ng-app elements (details here: https://git.io/v1b2r).
In later versions, Protractor will try to hook into all angular apps on the page. Use rootElement to limit the scope of which apps Protractor waits for and searches within.
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.
"Protractor will use bootstrapping" is a little unclear but that's definitely an improvement
5b40ed2 to
e5ea2a2
Compare
| return {$injector: $injector, $$testability: $$testability}; | ||
| } else { | ||
| return tryEl(document.body) || | ||
| trySelector('[ng-app]') || trySelector('[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.
@juliemr should this include ng_app too?
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 don't think anyone uses that... I'd leave it out. We can always add it later if there's a clamor.
|
@juliemr all comments addressed |
e5ea2a2 to
167862a
Compare
|
LGTM |
167862a to
15990ad
Compare
This is a breaking change because it changes the default root element behavior and removes the `config.useAllAngular2AppRoots` flag. Modern angular apps now default to using all app hooks, and ng1 apps now check several places, notably the element the app bootstraps to. Closes angular#1742
15990ad to
fc61050
Compare
Closes #1742