Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip linking if elemented already removed in the meantime #64

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions clickoutside.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,18 @@
return {
restrict: 'A',
link: function($scope, elem, attr) {
let isDestoyed = false;

$scope.$on('$destroy', function() {
isDestoyed = true;
});

// postpone linking to next digest to allow for unique id generation
$timeout(function() {
if (isDestoyed) {
return;
}

var classList = (attr.outsideIfNot !== undefined) ? attr.outsideIfNot.split(/[ ,]+/) : [],
fn;

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "iamadamjowett/angular-click-outside",
"name": "angular-click-outside",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

hack to make the script installable directly from repo. The above one is either typo (it has @ no more), or makes npm double check the source of the code.

"version": "2.11.0",
"main": "clickoutside.directive.js",
"author": {
Expand Down