Skip to content

Commit

Permalink
Check that events are defined before calling.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordan Humphreys committed Jul 28, 2016
1 parent 7ba9533 commit 6b7fd2b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@ var AngularTribute = function AngularTribute($timeout) {
$scope.tribute.attach($element[0]);

$element[0].addEventListener("tribute-replaced", function (e) {
if (typeof $scope.onReplaced !== 'function') return;
$timeout($scope.onReplaced.apply(_this));
});
$element[0].addEventListener("tribute-no-match", function (e) {
$timeout($scope.onReplaced.apply(_this));
if (typeof $scope.onNoMatch !== 'function') return;
$timeout($scope.onNoMatch.apply(_this));
});
};
}
Expand Down
4 changes: 3 additions & 1 deletion index.umd.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@
$scope.tribute.attach($element[0]);

$element[0].addEventListener("tribute-replaced", function (e) {
if (typeof $scope.onReplaced !== 'function') return;
$timeout($scope.onReplaced.apply(_this));
});
$element[0].addEventListener("tribute-no-match", function (e) {
$timeout($scope.onReplaced.apply(_this));
if (typeof $scope.onNoMatch !== 'function') return;
$timeout($scope.onNoMatch.apply(_this));
});
};
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-tribute",
"version": "0.0.2",
"version": "0.0.3",
"description": "An AngularJS wrapper for ZURB's Tribute library for native @mentions",
"license": "MIT",
"repository": "zurb/angular-tribute",
Expand Down
4 changes: 3 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@ const AngularTribute = ($timeout) => ({
$scope.tribute.attach($element[0]);

$element[0].addEventListener("tribute-replaced", (e) => {
if (typeof $scope.onReplaced !== 'function') return;
$timeout($scope.onReplaced.apply(this));
});
$element[0].addEventListener("tribute-no-match", (e) => {
$timeout($scope.onReplaced.apply(this));
if (typeof $scope.onNoMatch !== 'function') return;
$timeout($scope.onNoMatch.apply(this));
});
}
}
Expand Down

0 comments on commit 6b7fd2b

Please sign in to comment.