Skip to content

Commit 1f56144

Browse files
authored
Make bundles property not deeply reactive (fluent-vue#673)
1 parent 9af0a83 commit 1f56144

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
* @jest-environment jsdom
3+
*/
4+
5+
import { isReactive } from 'vue-demi'
6+
import { FluentBundle } from '@fluent/bundle'
7+
8+
import { createFluentVue } from '../src'
9+
10+
describe('performance checks', () => {
11+
it('bundles are not deeply reactive', () => {
12+
// Arrange
13+
const bundle = new FluentBundle('en-US')
14+
15+
// Act
16+
const fluent = createFluentVue({
17+
bundles: [bundle]
18+
})
19+
20+
// Assert
21+
for (const bundle of fluent.bundles) {
22+
expect(isReactive(bundle)).toEqual(false)
23+
}
24+
})
25+
})

packages/fluent-vue/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { InstallFunction, Vue, Vue2, Vue3, Vue3Component } from './types/typesCompat'
22
import type { FluentBundle, FluentVariable } from '@fluent/bundle'
33

4-
import { isVue3, ref, provide, Ref } from 'vue-demi'
4+
import { isVue3, shallowRef, provide } from 'vue-demi'
55
import { TranslationContext, TranslationWithAttrs } from './TranslationContext'
66
import { createVue2Directive, createVue3Directive } from './vue/directive'
77
import component from './vue/component'
@@ -34,7 +34,7 @@ export interface FluentVue {
3434
* @param options - {@link FluentVueOptions}
3535
*/
3636
export function createFluentVue (options: FluentVueOptions): FluentVue {
37-
const bundles: Ref<Iterable<FluentBundle>> = ref(options.bundles)
37+
const bundles = shallowRef(options.bundles)
3838

3939
const rootContext = new TranslationContext(bundles)
4040

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy