Skip to content

Commit dc8f255

Browse files
committed
chore: update
1 parent ed704f4 commit dc8f255

File tree

3 files changed

+161
-47
lines changed

3 files changed

+161
-47
lines changed

packages/compiler-core/__tests__/__snapshots__/parse.spec.ts.snap

Lines changed: 146 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2920,6 +2920,144 @@ exports[`compiler: parse > Errors > UNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME > <te
29202920
}
29212921
`;
29222922
2923+
exports[`compiler: parse > Errors > UNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME > <template><div foo "></div></template> 1`] = `
2924+
{
2925+
"cached": [],
2926+
"children": [
2927+
{
2928+
"children": [
2929+
{
2930+
"children": [],
2931+
"codegenNode": undefined,
2932+
"loc": {
2933+
"end": {
2934+
"column": 28,
2935+
"line": 1,
2936+
"offset": 27,
2937+
},
2938+
"source": "<div foo "></div>",
2939+
"start": {
2940+
"column": 11,
2941+
"line": 1,
2942+
"offset": 10,
2943+
},
2944+
},
2945+
"ns": 0,
2946+
"props": [
2947+
{
2948+
"loc": {
2949+
"end": {
2950+
"column": 19,
2951+
"line": 1,
2952+
"offset": 18,
2953+
},
2954+
"source": "foo",
2955+
"start": {
2956+
"column": 16,
2957+
"line": 1,
2958+
"offset": 15,
2959+
},
2960+
},
2961+
"name": "foo",
2962+
"nameLoc": {
2963+
"end": {
2964+
"column": 19,
2965+
"line": 1,
2966+
"offset": 18,
2967+
},
2968+
"source": "foo",
2969+
"start": {
2970+
"column": 16,
2971+
"line": 1,
2972+
"offset": 15,
2973+
},
2974+
},
2975+
"type": 6,
2976+
"value": undefined,
2977+
},
2978+
{
2979+
"loc": {
2980+
"end": {
2981+
"column": 21,
2982+
"line": 1,
2983+
"offset": 20,
2984+
},
2985+
"source": """,
2986+
"start": {
2987+
"column": 20,
2988+
"line": 1,
2989+
"offset": 19,
2990+
},
2991+
},
2992+
"name": """,
2993+
"nameLoc": {
2994+
"end": {
2995+
"column": 21,
2996+
"line": 1,
2997+
"offset": 20,
2998+
},
2999+
"source": """,
3000+
"start": {
3001+
"column": 20,
3002+
"line": 1,
3003+
"offset": 19,
3004+
},
3005+
},
3006+
"type": 6,
3007+
"value": undefined,
3008+
},
3009+
],
3010+
"tag": "div",
3011+
"tagType": 0,
3012+
"type": 1,
3013+
},
3014+
],
3015+
"codegenNode": undefined,
3016+
"loc": {
3017+
"end": {
3018+
"column": 39,
3019+
"line": 1,
3020+
"offset": 38,
3021+
},
3022+
"source": "<template><div foo "></div></template>",
3023+
"start": {
3024+
"column": 1,
3025+
"line": 1,
3026+
"offset": 0,
3027+
},
3028+
},
3029+
"ns": 0,
3030+
"props": [],
3031+
"tag": "template",
3032+
"tagType": 0,
3033+
"type": 1,
3034+
},
3035+
],
3036+
"codegenNode": undefined,
3037+
"components": [],
3038+
"directives": [],
3039+
"helpers": Set {},
3040+
"hoists": [],
3041+
"imports": [],
3042+
"loc": {
3043+
"end": {
3044+
"column": 39,
3045+
"line": 1,
3046+
"offset": 38,
3047+
},
3048+
"source": "<template><div foo "></div></template>",
3049+
"start": {
3050+
"column": 1,
3051+
"line": 1,
3052+
"offset": 0,
3053+
},
3054+
},
3055+
"source": "<template><div foo "></div></template>",
3056+
"temps": 0,
3057+
"type": 0,
3058+
}
3059+
`;
3060+
29233061
exports[`compiler: parse > Errors > UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE > <template><div foo=bar"></div></template> 1`] = `
29243062
{
29253063
"cached": [],
@@ -3558,39 +3696,7 @@ exports[`compiler: parse > Errors > UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME
35583696
},
35593697
},
35603698
"ns": 0,
3561-
"props": [
3562-
{
3563-
"loc": {
3564-
"end": {
3565-
"column": 17,
3566-
"line": 1,
3567-
"offset": 16,
3568-
},
3569-
"source": "=",
3570-
"start": {
3571-
"column": 16,
3572-
"line": 1,
3573-
"offset": 15,
3574-
},
3575-
},
3576-
"name": "=",
3577-
"nameLoc": {
3578-
"end": {
3579-
"column": 17,
3580-
"line": 1,
3581-
"offset": 16,
3582-
},
3583-
"source": "=",
3584-
"start": {
3585-
"column": 16,
3586-
"line": 1,
3587-
"offset": 15,
3588-
},
3589-
},
3590-
"type": 6,
3591-
"value": undefined,
3592-
},
3593-
],
3699+
"props": [],
35943700
"tag": "div",
35953701
"tagType": 0,
35963702
"type": 1,
@@ -3673,25 +3779,25 @@ exports[`compiler: parse > Errors > UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME
36733779
"line": 1,
36743780
"offset": 23,
36753781
},
3676-
"source": "=foo=bar",
3782+
"source": "foo=bar",
36773783
"start": {
3678-
"column": 16,
3784+
"column": 17,
36793785
"line": 1,
3680-
"offset": 15,
3786+
"offset": 16,
36813787
},
36823788
},
3683-
"name": "=foo",
3789+
"name": "foo",
36843790
"nameLoc": {
36853791
"end": {
36863792
"column": 20,
36873793
"line": 1,
36883794
"offset": 19,
36893795
},
3690-
"source": "=foo",
3796+
"source": "foo",
36913797
"start": {
3692-
"column": 16,
3798+
"column": 17,
36933799
"line": 1,
3694-
"offset": 15,
3800+
"offset": 16,
36953801
},
36963802
},
36973803
"type": 6,

packages/compiler-core/__tests__/parse.spec.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3219,6 +3219,15 @@ describe('compiler: parse', () => {
32193219
},
32203220
],
32213221
},
3222+
{
3223+
code: '<template><div foo "></div></template>',
3224+
errors: [
3225+
{
3226+
type: ErrorCodes.UNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME,
3227+
loc: { offset: 19, line: 1, column: 20 },
3228+
},
3229+
],
3230+
},
32223231
],
32233232
UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE: [
32243233
{

packages/compiler-core/src/tokenizer.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -651,17 +651,16 @@ export default class Tokenizer {
651651
this.state = State.BeforeTagName
652652
this.sectionStart = this.index
653653
} else if (!isWhitespace(c)) {
654-
if ((__DEV__ || !__BROWSER__) && c === CharCodes.Eq) {
655-
this.cbs.onerr(
656-
ErrorCodes.UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME,
657-
this.index,
658-
)
659-
}
660654
this.handleAttrStart(c)
661655
}
662656
}
663657
private handleAttrStart(c: number) {
664-
if (c === CharCodes.LowerV && this.peek() === CharCodes.Dash) {
658+
if ((__DEV__ || !__BROWSER__) && c === CharCodes.Eq) {
659+
this.cbs.onerr(
660+
ErrorCodes.UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME,
661+
this.index,
662+
)
663+
} else if (c === CharCodes.LowerV && this.peek() === CharCodes.Dash) {
665664
this.state = State.InDirName
666665
this.sectionStart = this.index
667666
} else if (

0 commit comments

Comments
 (0)