diff --git a/src/Bridges/ApplicationLatte/UIMacros.php b/src/Bridges/ApplicationLatte/UIMacros.php
index 7ee147145..853d03589 100644
--- a/src/Bridges/ApplicationLatte/UIMacros.php
+++ b/src/Bridges/ApplicationLatte/UIMacros.php
@@ -100,8 +100,10 @@ public function macroLink(MacroNode $node, PhpWriter $writer)
*/
public function macroIfCurrent(MacroNode $node, PhpWriter $writer)
{
- return $writer->write(($node->args ? 'try { $_presenter->link(%node.word, %node.array?); } catch (Nette\Application\UI\InvalidLinkException $e) {}' : '')
- . '; if ($_presenter->getLastCreatedRequestFlag("current")) {');
+ return $writer->write($node->args
+ ? 'if ($_presenter->isLinkCurrent(%node.word, %node.array?)) {'
+ : 'if ($_presenter->getLastCreatedRequestFlag("current")) {'
+ );
}
diff --git a/tests/Application.Latte/UIMacros.isLinkCurrent.phpt b/tests/Application.Latte/UIMacros.isLinkCurrent.phpt
index 2adeae6da..9ea908619 100644
--- a/tests/Application.Latte/UIMacros.isLinkCurrent.phpt
+++ b/tests/Application.Latte/UIMacros.isLinkCurrent.phpt
@@ -23,4 +23,8 @@ Assert::matchFile(__DIR__ . '/expected/UIMacros.isLinkCurrent.phtml', $latte->co
href before n:class
href after n:class
+
+{ifCurrent}empty{/ifCurrent}
+
+{ifCurrent default}default{/ifCurrent}
'));
diff --git a/tests/Application.Latte/expected/UIMacros.isLinkCurrent.phtml b/tests/Application.Latte/expected/UIMacros.isLinkCurrent.phtml
index 50383672a..792e5f5dc 100644
--- a/tests/Application.Latte/expected/UIMacros.isLinkCurrent.phtml
+++ b/tests/Application.Latte/expected/UIMacros.isLinkCurrent.phtml
@@ -5,5 +5,11 @@
href before n:class
href after n:class
+
+getLastCreatedRequestFlag("current")) { ?>empty
+
+
+isLinkCurrent("default")) { ?>default
+