-
Notifications
You must be signed in to change notification settings - Fork 344
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: useCSSModule to adapt the change of getCurrentInstance, close #620…
… (#622) * fix(useCssModule): adapting the behavior of `useCSSModule` to the change of `getCurrentInstance`. close #620 * chores: add test for `useCssModule`.
- Loading branch information
Showing
2 changed files
with
32 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
const Vue = require('vue/dist/vue.common.js') | ||
const { useCSSModule } = require('../../src') | ||
|
||
const style = { whateverStyle: 'whateverStyle' } | ||
|
||
function injectStyles() { | ||
Object.defineProperty(this, '$style', { | ||
configurable: true, | ||
get: function () { | ||
return style | ||
}, | ||
}) | ||
} | ||
|
||
describe('api/useCssModule', () => { | ||
it('should get the same object', (done) => { | ||
const vm = new Vue({ | ||
beforeCreate() { | ||
injectStyles.call(this) | ||
}, | ||
template: '<div>{{style}}</div>', | ||
setup() { | ||
const style = useCSSModule() | ||
return { style } | ||
}, | ||
}) | ||
vm.$mount() | ||
expect(vm.style).toBe(style) | ||
done() | ||
}) | ||
}) |