Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
/angular.jsPublic archive

feat($rootScope): implement event.stopPropagation() for $broadcast-ed events#12672

Open
just-boris wants to merge1 commit intoangular:master
base:master
Choose a base branch
Loading
fromjust-boris:broadcast-propagation
Open

feat($rootScope): implement event.stopPropagation() for $broadcast-ed events#12672

just-boris wants to merge1 commit intoangular:masterfromjust-boris:broadcast-propagation

Conversation

just-boris
Copy link
Contributor

It would more consistent if both ways to trigger an event will havestopPropagation feature.

Implemented as described in#914

Also there is a related question onstackoverlow.

@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project, in which case you'll need to sign a Contributor License Agreement (CLA).

📝Please visithttps://cla.developers.google.com/ to sign.

Once you've signed, please reply here (e.g.I signed it!) and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Checkyour existing CLA data and verify that youremail is set on your git commits.
  • If you signed the CLA as a corporation, please let us know the company's name.

@just-boris
Copy link
ContributorAuthor

I signed it asjust-boris@hotmail.com

@just-boris
Copy link
ContributorAuthor

I signed it!

if (!(next = ((current.$$listenerCount[name] && current.$$childHead) ||
(current !== target && current.$$nextSibling)))) {
if (!(next = ((current.$$listenerCount[name] &&!stopPropagation &&current.$$childHead) ||
(current !== target &&((stopPropagation = false) ||current.$$nextSibling))))) {
Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Maybe it should split that complicated expression into moreifs?
But then it will be completely different than traversal in$digest

@googlebot
Copy link

CLAs look good, thanks!

@Narretz
Copy link
Contributor

I am not sure what the reasons were for not having stopPropagation on broadcast. However, what's the use case for using stopPropagation this way? Normally, you use events pretty sparingly in an angular app.

}));


iit('should stop propagation only for one scope chain', inject(function($rootScope) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

iit -> it

@just-boris
Copy link
ContributorAuthor

@Narretz fixed. Now all tests are passing fine.

The reasons are similar to stoping$emit-ed events. If some component on top level already handled this event (showed popover, for example), then children don't need to handle this event again. Now as a workaround I have to use some flags and check that on children and code looks ugly.

I guess that wasn't implemented earlier, because it is more rare case than$emit and harder to implement (you need to stop only one branch in the tree and go on by others).

Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers
No reviews
Assignees
No one assigned
Projects
None yet
Milestone
Ice Box
Development

Successfully merging this pull request may close these issues.

3 participants
@just-boris@googlebot@Narretz

[8]ページ先頭

©2009-2025 Movatter.jp