-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
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
Improve terminalable directive #2272
Conversation
Thanks for the PR! This one takes some time to review, but I'll do it as soon as I can 👍 |
Thanks!! 😺 |
linker(vm, el) | ||
expect(vm._bindDir.calls.count()).toBe(1) | ||
var args = vm._bindDir.calls.argsFor(0) | ||
expect(args[0].name).toBe('term') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps assign the args[0] to a variable.
7b44774
to
d8b261b
Compare
ping @yyx990803 |
if (value != null) { | ||
return makeTerminalNodeLinkFn(el, dirName, value, options) | ||
|
||
var terminals = terminalDirectives.map(function (terminal) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These change seems pretty expensive since it's now map + sort + nested for loop for every single element compiled. Ideally we want to move as much work out of this function as possible.
Here's what I think what should be the ideal API: the custom directive should just declare With this, the
Does this make sense? I may have overlooked something but I think this could make it more efficient and more consistent. |
Do want. This will allow to make things like vue-transfer-dom truly reusable (i.e. without |
I totally agree with the approach not to monkey patch parts of the core API. This clearly has a use case that makes sense to easily implement, with future extentions this will become ever more requested. |
@yyx990803 When I'm implementing the patch of this PR, I felt that I'll try to challenge based on your feedback. 😸 |
3171645
to
d7316c0
Compare
@yyx990803 updated |
} | ||
} | ||
|
||
if (termDef) { | ||
return makeTerminalNodeLinkFn(el, dirName, value, options, termDef, name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can already extract arg as matched[2]
here, and can just use that and pass it to makeTerminalNodeLinkFn
instead of using argRE
.
Support the followings: - Directive instance properties: `arg`, `modifiers` - Priority for terminal directive BREAKING CHANGES: - API: Change internal `terminalDirectives` array to `terminal: true` directive options
d7316c0
to
9236191
Compare
@yyx990803 This PR is breaking change of custom terminal directives. |
@kazupon yes. Custom terminal directives were not publicly documented though, so technically this is a new feature. One case I can think of is https://github.com/rhyzx/vue-transfer-dom may need to be updated to use the new API. /cc @rhyzx |
Improve terminalable directive
Merged! 🎉 |
@yyx990803 As next step, I'll try to write the documentation. |
There are times when we want to use the
arg
andmodifires
in custom terminal directive, and control the priority.e.g.
Recently, in the following related issues or PR, we became able to define the terminal directive.
allow empty expression in terminal directives #2137
transfer DOM #2130
However, we can not yet.
I fixed this issues.
I hope that this PR are merged with you.
Please check the codes.