Repository navigation
fix(aio): handle clicks deep within anchor tags - #16131
Conversation
|
The angular.io preview for b52f0de76e577eb8a4036a218de83082b1894828 is available here. |
|
Failing the Travis saucelabs task. Flake? |
gkalpak
left a comment
There was a problem hiding this comment.
I wonder (mostly ooc) why we have stuff wrapped deeply in anchors, but if we must this LGTM (with the test fixed).
There was a problem hiding this comment.
No need for instanceof check any more. If it is truthy, it will be an HTMLAnchorElement.
There was a problem hiding this comment.
I suggest that you simplify this code by using innerHTML which makes the whole thing way more readable:
fixture.nativeElement.innerHTML="<a href='some/url'><div><img></div></a>"
const imageElement = fixture.nativeElement.findElementByTagName('img');
imageElement.click();
3 readable lines vs 8 error prone lines of code. simple is better. :)
There was a problem hiding this comment.
use the same declarative approach as I explained above.
b52f0de to
e760b2d
Compare
|
Thanks. Review again please. |
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Several docs (e.g., "Docs" guide page) surround arbitrary HTML content in anchor tags. Our previous logic in
AppComponentlooked only at theeventTargetparent (and then only if theeventTargetwas an image). This was inadequate. Clicking on any other nested content triggered an unwanted page refresh because we did not find the anchor.In this fix, the click interception analysis climbs the ancestor tree until it finds an anchor tag to analyze and, potentially, intercept. If it doesn't find an anchor, the default click handling is allowed (returns
true).Please check if the PR fulfills these requirements
What kind of change does this PR introduce? (check one with "x")