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(vue-app): check plugin key on Vue.prototype instead of Vue #7656

Merged
merged 1 commit into from Jul 2, 2020

Conversation

simplesmiler
Copy link

Fix for an obscure bug that got introduced in e8aca9e.
Triggered when you inject something under a key, that was already used by other library.

Types of changes

  • Bug fix (a non-breaking change which fixes an issue)
  • New feature (a non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Description

Example (using https://github.com/stalniy/casl/tree/master/packages/casl-vue):

// plugins/casl.js
import Vue from 'vue';
import { Ability, abilitiesPlugin } from '@casl/vue';
export default function(context, inject) {
   const ability = new Ability(...);
   Vue.use(abilitiesPlugin, { ability }); // defines $ability and $can on Vue.prototype
   inject('ability', ability); // error: Can not redefine '$ability'
}

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly. (PR: #)
  • I have added tests to cover my changes (if not applicable, please state why)
  • All new and existing tests are passing.

@simplesmiler
Copy link
Author

Also, it appears that a proper reentrance check is done above via installKey. Because of this, maybe we should warn developer instead of silently skipping?

@codecov-commenter
Copy link

Codecov Report

Merging #7656 into dev will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##              dev    #7656   +/-   ##
=======================================
  Coverage   70.18%   70.18%           
=======================================
  Files          88       88           
  Lines        3756     3756           
  Branches     1020     1020           
=======================================
  Hits         2636     2636           
  Misses        911      911           
  Partials      209      209           
Flag Coverage Δ
#unittests 70.18% <ø> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2302ffa...6fa4944. Read the comment docs.

@pi0 pi0 changed the title fix: check plugin key on Vue.prototype instead of Vue fix(vue-app): check plugin key on Vue.prototype instead of Vue Jul 2, 2020
@pi0 pi0 merged commit d4363d4 into nuxt:dev Jul 2, 2020
@pi0 pi0 mentioned this pull request Jul 2, 2020
@danielroe danielroe added the 2.x label Jan 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants