• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Haixing-Hu / vue3-class-component / 7c8a3f3e-046f-4ced-b630-a0c6636a0ccb

09 Jun 2025 08:22AM UTC coverage: 100.0%. Remained the same
7c8a3f3e-046f-4ced-b630-a0c6636a0ccb

push

circleci

Haixing-Hu
chore: update yarn.lock after dependency changes

151 of 151 branches covered (100.0%)

Branch coverage included in aggregate %.

222 of 222 relevant lines covered (100.0%)

19.39 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/src/impl/decorator/fix-default-value.js
1
////////////////////////////////////////////////////////////////////////////////
2
//
3
//    Copyright (c) 2022 - 2024.
4
//    Haixing Hu, Qubit Co. Ltd.
5
//
6
//    All rights reserved.
7
//
8
////////////////////////////////////////////////////////////////////////////////
9

10
/**
11
 * Fix the default value.
12
 *
13
 * Note that according to the document of Vue.js, if the default value of a Prop
14
 * or an injected property is an Object or an Array, it must be defined with a
15
 * factory function which returns the default value.
16
 *
17
 * See <a href="https://vuejs.org/api/options-state.html#props">Props</a> and
18
 * <a href="https://vuejs.org/api/options-composition.html#inject">Inject</a>
19
 * for details.
20
 *
21
 * @param {any} value
22
 *     the inferred default value.
23
 * @return {any | Function}
24
 * @see <a href="https://vuejs.org/api/options-state.html#props">Props</a>
25
 * @see <a href="https://vuejs.org/api/options-composition.html#inject">Inject</a>
26
 * @author Haixing Hu
27
 * @private
28
 */
29
function fixDefaultValue(value) {
30
  if (value === undefined) {
21✔
31
    return undefined;
10✔
32
  } else if (value === null) {
11✔
33
    return null;
1✔
34
  } else if (Array.isArray(value) || (value instanceof Object)) {
10✔
35
    return () => value;   // returns the factory function
4✔
36
  } else {
37
    return value;
6✔
38
  }
39
}
40

41
export default fixDefaultValue;
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc