Skip to content

Implements plugin parameters #118

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

Merged
merged 1 commit into from
Feb 20, 2014
Merged

Implements plugin parameters #118

merged 1 commit into from
Feb 20, 2014

Conversation

bpierre
Copy link

@bpierre bpierre commented Feb 20, 2014

Small change: every additional parameters is passed to the function instead of a single options param. As a consequence, this is set to the current ViewModel if the plugin is a function.

Tell me if that’s OK, otherwise I will change it to respect what you said in #88. I will also make a pull request on https://github.com/vuejs/vuejs.org.

@@ -66,10 +66,15 @@ ViewModel.use = function (plugin) {
return utils.warn('Cannot find plugin: ' + plugin)
}
}

// additional parameters
var args = Array.prototype.slice.call(arguments, 1)
Copy link
Member

Choose a reason for hiding this comment

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

Why slice then unshift here? It seems simply plugin.install.apply(plugin, arguments) will do.

Copy link
Author

Choose a reason for hiding this comment

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

Because I want to replace arguments[0] with ViewModel (otherwise, arguments[0] is the plugin function / string / object), and arguments[0] cannot be reassigned.

Copy link
Member

Choose a reason for hiding this comment

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

Oh you're right, I was reading the code out of context...

Copy link
Member

Choose a reason for hiding this comment

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

Can you use [].slice here? This function is not perf sensitive and it could save a few bytes :)

Copy link
Author

Choose a reason for hiding this comment

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

Sure! I was using Array.prototype.slice for performance reasons, but you are right :)

yyx990803 added a commit that referenced this pull request Feb 20, 2014
@yyx990803 yyx990803 merged commit 676b4d0 into vuejs:dev Feb 20, 2014
@bpierre bpierre deleted the plugin-options branch February 20, 2014 16:55
@yyx990803
Copy link
Member

Landed! Thanks a lot :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants