File tree Expand file tree Collapse file tree 1 file changed +24
-8
lines changed
packages/runtime-core/src Expand file tree Collapse file tree 1 file changed +24
-8
lines changed Original file line number Diff line number Diff line change @@ -115,11 +115,19 @@ export function setRef(
115
115
} else {
116
116
if ( ! isArray ( existing ) ) {
117
117
if ( _isString ) {
118
- if ( oldRef !== ref ) {
119
- refs [ ref ] = [ refValue ]
120
- if ( canSetSetupRef ( ref ) ) {
121
- setupState [ ref ] = refs [ ref ]
118
+ if ( oldRef === ref ) {
119
+ if ( __DEV__ && ! __TEST__ ) {
120
+ warn (
121
+ 'Duplicate template ref detected:' ,
122
+ ref ,
123
+ `(${ typeof ref } ). Ref names must be unique within the same scope.` ,
124
+ )
122
125
}
126
+ return
127
+ }
128
+ refs [ ref ] = [ refValue ]
129
+ if ( canSetSetupRef ( ref ) ) {
130
+ setupState [ ref ] = refs [ ref ]
123
131
}
124
132
} else {
125
133
ref . value = [ refValue ]
@@ -130,11 +138,19 @@ export function setRef(
130
138
}
131
139
}
132
140
} else if ( _isString ) {
133
- if ( oldRef !== ref ) {
134
- refs [ ref ] = value
135
- if ( canSetSetupRef ( ref ) ) {
136
- setupState [ ref ] = value
141
+ if ( oldRef === ref ) {
142
+ if ( __DEV__ && ! __TEST__ ) {
143
+ warn (
144
+ 'Duplicate template ref detected:' ,
145
+ ref ,
146
+ `(${ typeof ref } ). Ref names must be unique within the same scope.` ,
147
+ )
137
148
}
149
+ return
150
+ }
151
+ refs [ ref ] = value
152
+ if ( canSetSetupRef ( ref ) ) {
153
+ setupState [ ref ] = value
138
154
}
139
155
} else if ( _isRef ) {
140
156
ref . value = value
You can’t perform that action at this time.
0 commit comments