Skip to content

Commit 84aa0c0

Browse files
authored
fix: drop preserve checking logic (#213)
1 parent 8d9c960 commit 84aa0c0

File tree

3 files changed

+0
-34
lines changed

3 files changed

+0
-34
lines changed

src/report.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ export const enum ReportCodes {
2222
FAILED_VALUE_EVALUATION,
2323
REQUIRED_PARAMETER,
2424
INVALID_PARAMETER_TYPE,
25-
NOT_SUPPORTED_PRESERVE,
2625
OVERRIDE_ELEMENT_CHILDREN,
2726
NOT_RESOLVED_COMPOSER,
2827
UNEXPECTED_ERROR,
@@ -36,7 +35,6 @@ const ReportMessages: { [code: number]: string } = {
3635
[ReportCodes.FAILED_VALUE_EVALUATION]: `Failed value evaluation: {0}`,
3736
[ReportCodes.REQUIRED_PARAMETER]: `Required parameter: {0}`,
3837
[ReportCodes.INVALID_PARAMETER_TYPE]: `Required parameter: {0}`,
39-
[ReportCodes.NOT_SUPPORTED_PRESERVE]: `Not supported 'preserve': {0}`,
4038
[ReportCodes.OVERRIDE_ELEMENT_CHILDREN]: `v-t will override element children: {0}`,
4139
[ReportCodes.NOT_RESOLVED_COMPOSER]: `Not resolved vue-i18n composer: {0}`,
4240
[ReportCodes.UNEXPECTED_ERROR]: `Unexpected error: {0}`

src/transform.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -169,13 +169,6 @@ export function transformVTDirective<
169169
node.children.length = 0
170170
}
171171

172-
if (dir.modifiers.includes('preserve')) {
173-
report(ReportCodes.NOT_SUPPORTED_PRESERVE, {
174-
args: [node.loc.source || ''],
175-
loc: node.loc
176-
})
177-
}
178-
179172
if (isSimpleExpressionNode(exp)) {
180173
if (isConstant(exp) && i18nInstance) {
181174
const { status, value } = evaluateValue(exp.content)

test/transform.test.ts

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,6 @@ import { transformVTDirective } from '../src/transform'
66
import { getReportMessage, ReportCodes } from '../src/report'
77
import { mount } from './helper'
88

9-
function getMessage(code: ReportCodes, ...args: unknown[]) {
10-
return `[vue-i18n-extensions] ${getReportMessage(code, ...args)}`
11-
}
12-
13-
let spyWarn: ReturnType<typeof vi.spyOn>
14-
beforeEach(() => {
15-
spyWarn = vi.spyOn(global.console, 'warn') as ReturnType<typeof vi.spyOn>
16-
})
17-
189
afterEach(() => {
1910
// vi.clearAllMocks()
2011
// vi.resetAllMocks()
@@ -77,22 +68,6 @@ describe('binding', () => {
7768
})
7869
})
7970

80-
test('preserve modifier', () => {
81-
spyWarn.mockImplementation(() => {})
82-
83-
const transformVT = transformVTDirective()
84-
const source = `<div v-t.preserve="'hello'"/>`
85-
const { code, ast } = compile(source, {
86-
mode: 'function',
87-
hoistStatic: false,
88-
prefixIdentifiers: true,
89-
directiveTransforms: { t: transformVT }
90-
})
91-
expect(code).toMatchSnapshot(source)
92-
expect(ast).toMatchSnapshot(source)
93-
expect(spyWarn.mock.calls[0][0]).toEqual(getMessage(ReportCodes.NOT_SUPPORTED_PRESERVE, source))
94-
})
95-
9671
test('no specify', () => {
9772
const transformVT = transformVTDirective()
9873
const source = `<div v-t=""/>`

0 commit comments

Comments
 (0)