@@ -119,14 +119,14 @@ export function parse(template: string, options: CompilerOptions): ASTElement {
119
119
if ( ! stack . length && element !== root ) {
120
120
// allow root elements with v-if, v-else-if and v-else
121
121
if ( root . if && ( element . elseif || element . else ) ) {
122
- if ( process . env . NODE_ENV !== 'production' ) {
122
+ if ( __DEV__ ) {
123
123
checkRootConstraints ( element )
124
124
}
125
125
addIfCondition ( root , {
126
126
exp : element . elseif ,
127
127
block : element
128
128
} )
129
- } else if ( process . env . NODE_ENV !== 'production' ) {
129
+ } else if ( __DEV__ ) {
130
130
warnOnce (
131
131
`Component template should contain exactly one root element. ` +
132
132
`If you are using v-if on multiple elements, ` +
@@ -229,7 +229,7 @@ export function parse(template: string, options: CompilerOptions): ASTElement {
229
229
element . ns = ns
230
230
}
231
231
232
- if ( process . env . NODE_ENV !== 'production' ) {
232
+ if ( __DEV__ ) {
233
233
if ( options . outputSourceRange ) {
234
234
element . start = start
235
235
element . end = end
@@ -254,7 +254,7 @@ export function parse(template: string, options: CompilerOptions): ASTElement {
254
254
255
255
if ( isForbiddenTag ( element ) && ! isServerRendering ( ) ) {
256
256
element . forbidden = true
257
- process . env . NODE_ENV !== 'production' &&
257
+ __DEV__ &&
258
258
warn (
259
259
'Templates should only be responsible for mapping the state to the ' +
260
260
'UI. Avoid placing tags with side-effects in your templates, such as ' +
@@ -289,7 +289,7 @@ export function parse(template: string, options: CompilerOptions): ASTElement {
289
289
290
290
if ( ! root ) {
291
291
root = element
292
- if ( process . env . NODE_ENV !== 'production' ) {
292
+ if ( __DEV__ ) {
293
293
checkRootConstraints ( root )
294
294
}
295
295
}
@@ -307,15 +307,15 @@ export function parse(template: string, options: CompilerOptions): ASTElement {
307
307
// pop stack
308
308
stack . length -= 1
309
309
currentParent = stack [ stack . length - 1 ]
310
- if ( process . env . NODE_ENV !== 'production' && options . outputSourceRange ) {
310
+ if ( __DEV__ && options . outputSourceRange ) {
311
311
element . end = end
312
312
}
313
313
closeElement ( element )
314
314
} ,
315
315
316
316
chars ( text : string , start : number , end : number ) {
317
317
if ( ! currentParent ) {
318
- if ( process . env . NODE_ENV !== 'production' ) {
318
+ if ( __DEV__ ) {
319
319
if ( text === template ) {
320
320
warnOnce (
321
321
'Component template requires a root element, rather than just text.' ,
@@ -382,10 +382,7 @@ export function parse(template: string, options: CompilerOptions): ASTElement {
382
382
}
383
383
}
384
384
if ( child ) {
385
- if (
386
- process . env . NODE_ENV !== 'production' &&
387
- options . outputSourceRange
388
- ) {
385
+ if ( __DEV__ && options . outputSourceRange ) {
389
386
child . start = start
390
387
child . end = end
391
388
}
@@ -402,10 +399,7 @@ export function parse(template: string, options: CompilerOptions): ASTElement {
402
399
text,
403
400
isComment : true
404
401
}
405
- if (
406
- process . env . NODE_ENV !== 'production' &&
407
- options . outputSourceRange
408
- ) {
402
+ if ( __DEV__ && options . outputSourceRange ) {
409
403
child . start = start
410
404
child . end = end
411
405
}
@@ -465,7 +459,7 @@ export function processElement(element: ASTElement, options: CompilerOptions) {
465
459
function processKey ( el ) {
466
460
const exp = getBindingAttr ( el , 'key' )
467
461
if ( exp ) {
468
- if ( process . env . NODE_ENV !== 'production' ) {
462
+ if ( __DEV__ ) {
469
463
if ( el . tag === 'template' ) {
470
464
warn (
471
465
`<template> cannot be keyed. Place the key on real elements instead.` ,
@@ -508,7 +502,7 @@ export function processFor(el: ASTElement) {
508
502
const res = parseFor ( exp )
509
503
if ( res ) {
510
504
extend ( el , res )
511
- } else if ( process . env . NODE_ENV !== 'production' ) {
505
+ } else if ( __DEV__ ) {
512
506
warn ( `Invalid v-for expression: ${ exp } ` , el . rawAttrsMap [ 'v-for' ] )
513
507
}
514
508
}
@@ -566,7 +560,7 @@ function processIfConditions(el, parent) {
566
560
exp : el . elseif ,
567
561
block : el
568
562
} )
569
- } else if ( process . env . NODE_ENV !== 'production' ) {
563
+ } else if ( __DEV__ ) {
570
564
warn (
571
565
`v-${ el . elseif ? 'else-if="' + el . elseif + '"' : 'else' } ` +
572
566
`used on element <${ el . tag } > without corresponding v-if.` ,
@@ -581,7 +575,7 @@ function findPrevElement(children: Array<any>): ASTElement | void {
581
575
if ( children [ i ] . type === 1 ) {
582
576
return children [ i ]
583
577
} else {
584
- if ( process . env . NODE_ENV !== 'production' && children [ i ] . text !== ' ' ) {
578
+ if ( __DEV__ && children [ i ] . text !== ' ' ) {
585
579
warn (
586
580
`text "${ children [ i ] . text . trim ( ) } " between v-if and v-else(-if) ` +
587
581
`will be ignored.` ,
@@ -614,7 +608,7 @@ function processSlotContent(el) {
614
608
if ( el . tag === 'template' ) {
615
609
slotScope = getAndRemoveAttr ( el , 'scope' )
616
610
/* istanbul ignore if */
617
- if ( process . env . NODE_ENV !== 'production' && slotScope ) {
611
+ if ( __DEV__ && slotScope ) {
618
612
warn (
619
613
`the "scope" attribute for scoped slots have been deprecated and ` +
620
614
`replaced by "slot-scope" since 2.5. The new "slot-scope" attribute ` +
@@ -627,7 +621,7 @@ function processSlotContent(el) {
627
621
el . slotScope = slotScope || getAndRemoveAttr ( el , 'slot-scope' )
628
622
} else if ( ( slotScope = getAndRemoveAttr ( el , 'slot-scope' ) ) ) {
629
623
/* istanbul ignore if */
630
- if ( process . env . NODE_ENV !== 'production' && el . attrsMap [ 'v-for' ] ) {
624
+ if ( __DEV__ && el . attrsMap [ 'v-for' ] ) {
631
625
warn (
632
626
`Ambiguous combined usage of slot-scope and v-for on <${ el . tag } > ` +
633
627
`(v-for takes higher priority). Use a wrapper <template> for the ` +
@@ -659,7 +653,7 @@ function processSlotContent(el) {
659
653
// v-slot on <template>
660
654
const slotBinding = getAndRemoveAttrByRegex ( el , slotRE )
661
655
if ( slotBinding ) {
662
- if ( process . env . NODE_ENV !== 'production' ) {
656
+ if ( __DEV__ ) {
663
657
if ( el . slotTarget || el . slotScope ) {
664
658
warn ( `Unexpected mixed usage of different slot syntaxes.` , el )
665
659
}
@@ -680,7 +674,7 @@ function processSlotContent(el) {
680
674
// v-slot on component, denotes default slot
681
675
const slotBinding = getAndRemoveAttrByRegex ( el , slotRE )
682
676
if ( slotBinding ) {
683
- if ( process . env . NODE_ENV !== 'production' ) {
677
+ if ( __DEV__ ) {
684
678
if ( ! maybeComponent ( el ) ) {
685
679
warn (
686
680
`v-slot can only be used on components or <template>.` ,
@@ -729,7 +723,7 @@ function getSlotName(binding) {
729
723
if ( ! name ) {
730
724
if ( binding . name [ 0 ] !== '#' ) {
731
725
name = 'default'
732
- } else if ( process . env . NODE_ENV !== 'production' ) {
726
+ } else if ( __DEV__ ) {
733
727
warn ( `v-slot shorthand syntax requires a slot name.` , binding )
734
728
}
735
729
}
@@ -744,7 +738,7 @@ function getSlotName(binding) {
744
738
function processSlotOutlet ( el ) {
745
739
if ( el . tag === 'slot' ) {
746
740
el . slotName = getBindingAttr ( el , 'name' )
747
- if ( process . env . NODE_ENV !== 'production' && el . key ) {
741
+ if ( __DEV__ && el . key ) {
748
742
warn (
749
743
`\`key\` does not work on <slot> because slots are abstract outlets ` +
750
744
`and can possibly expand into multiple elements. ` +
@@ -791,10 +785,7 @@ function processAttrs(el) {
791
785
if ( isDynamic ) {
792
786
name = name . slice ( 1 , - 1 )
793
787
}
794
- if (
795
- process . env . NODE_ENV !== 'production' &&
796
- value . trim ( ) . length === 0
797
- ) {
788
+ if ( __DEV__ && value . trim ( ) . length === 0 ) {
798
789
warn (
799
790
`The value for a v-bind expression cannot be empty. Found in "v-bind:${ name } "`
800
791
)
@@ -885,13 +876,13 @@ function processAttrs(el) {
885
876
modifiers ,
886
877
list [ i ]
887
878
)
888
- if ( process . env . NODE_ENV !== 'production' && name === 'model' ) {
879
+ if ( __DEV__ && name === 'model' ) {
889
880
checkForAliasModel ( el , value )
890
881
}
891
882
}
892
883
} else {
893
884
// literal attribute
894
- if ( process . env . NODE_ENV !== 'production' ) {
885
+ if ( __DEV__ ) {
895
886
const res = parseText ( value , delimiters )
896
887
if ( res ) {
897
888
warn (
@@ -942,12 +933,7 @@ function parseModifiers(name: string): Object | void {
942
933
function makeAttrsMap ( attrs : Array < Record < string , any > > ) : Record < string , any > {
943
934
const map = { }
944
935
for ( let i = 0 , l = attrs . length ; i < l ; i ++ ) {
945
- if (
946
- process . env . NODE_ENV !== 'production' &&
947
- map [ attrs [ i ] . name ] &&
948
- ! isIE &&
949
- ! isEdge
950
- ) {
936
+ if ( __DEV__ && map [ attrs [ i ] . name ] && ! isIE && ! isEdge ) {
951
937
warn ( 'duplicate attribute: ' + attrs [ i ] . name , attrs [ i ] )
952
938
}
953
939
map [ attrs [ i ] . name ] = attrs [ i ] . value
0 commit comments