Skip to content
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

[Fix] functional SFC style injection support #797

Merged
merged 2 commits into from
May 2, 2017

Conversation

blake-newman
Copy link
Member

Adds support for SFC components that have injectStyles.

Example component:

<script>
  export default {
    functional: true,
    render(h, { children }) {
      return h('div', children);
    },
  };
</script>

<style lang="scss">
  @import 'style/settings';
  @import 'style/tools';
  @import 'style/components/wrapper';
</style>

Also does not apply hook to functional components, without injectStyles. I believe that this is not needed, correct me if i'm wrong.

if (hook && options.functional && injectStyles) {
// inject styles for functioal component in vue file
const existing = options.render
options.render = function renderWithStyleInjection (...args) {
Copy link
Member

Choose a reason for hiding this comment

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

This piece of code will run in browser without compilation so we need to use ES5

@blake-newman blake-newman force-pushed the fix/styles-with-functional-vue-file branch from 067bd33 to bea3e64 Compare May 2, 2017 08:14
@blake-newman
Copy link
Member Author

@yyx990803 Updated to use es5

if (hook) {
if (hook && options.functional && injectStyles) {
// inject styles for functioal component in vue file
const existing = options.render
Copy link
Member

Choose a reason for hiding this comment

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

const is still es6 ;)

Copy link
Member Author

Choose a reason for hiding this comment

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

Damn so used to writing ES6 now :D

@blake-newman blake-newman force-pushed the fix/styles-with-functional-vue-file branch from bea3e64 to 354f063 Compare May 2, 2017 08:53
@yyx990803 yyx990803 merged commit 7cb64a4 into master May 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants