Skip to content

Commit 0def7bc

Browse files
authored
ref(vue): Use string.repeat() (#6663)
1 parent 92e951f commit 0def7bc

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

packages/vue/src/components.ts

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,8 @@ const ROOT_COMPONENT_NAME = '<Root>';
88
const ANONYMOUS_COMPONENT_NAME = '<Anonymous>';
99

1010
const repeat = (str: string, n: number): string => {
11-
let res = '';
12-
while (n) {
13-
if (n % 2 === 1) {
14-
res += str;
15-
}
16-
if (n > 1) {
17-
str += str; // eslint-disable-line no-param-reassign
18-
}
19-
n >>= 1; // eslint-disable-line no-bitwise, no-param-reassign
20-
}
21-
return res;
11+
// string.repeat() is not supported by IE11, we fall back to just using the string in that case
12+
return str.repeat ? str.repeat(n) : str;
2213
};
2314

2415
export const formatComponentName = (vm?: ViewModel, includeFile?: boolean): string => {

0 commit comments

Comments
 (0)