Custom $parent Magic Property #4345
Unanswered
Jagadish056
asked this question in
1. Help
Replies: 1 comment 19 replies
-
Sadly no. It's just standard javascript, you can't have something that it's a callback and a value at the same time. |
Beta Was this translation helpful? Give feedback.
19 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I’m trying to create a custom
$parent
magic property inspired by the Nesting Components. Here’s my current implementation:However, I encountered an issue:
$parent
returns the callback instead of the expected value when called directly.$parent()
works as expected, and$parent(2)
or$parent(10)
also work correctly.$parent(1, document.querySelector('#myDiv'))
works fine and returns the parent node of idmyDiv
elementIs there a way to modify this magic property to work when called without parentheses, like
$parent
, without returning the callback itself?Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions