执行过npm install命令的vue-element-admin源码
康凯
2022-05-20 aa4c235a8ca67ea8b731f90c951a465e92c0a865
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
"use strict";
 
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
const { parseFloatingPointNumber } = require("../helpers/strings");
const { getLabelsForLabelable } = require("../helpers/form-controls");
 
class HTMLMeterElementImpl extends HTMLElementImpl {
  constructor(args, privateData) {
    super(args, privateData);
    this._labels = null;
  }
 
  // https://html.spec.whatwg.org/multipage/form-elements.html#concept-meter-minimum
  get _minimumValue() {
    const min = this.getAttribute("min");
    if (min === null) {
      return 0;
    }
    const parsed = parseFloatingPointNumber(min);
    if (Number.isNaN(parsed)) {
      return 0;
    }
    return parsed;
  }
 
  // https://html.spec.whatwg.org/multipage/form-elements.html#concept-meter-maximum
  get _maximumValue() {
    let candidate = 1.0;
 
    const max = this.getAttribute("max");
    if (max !== null) {
      const parsed = parseFloatingPointNumber(max);
      if (!Number.isNaN(parsed)) {
        candidate = parsed;
      }
    }
 
    const minimumValue = this._minimumValue;
    return candidate >= minimumValue ? candidate : minimumValue;
  }
 
  // https://html.spec.whatwg.org/multipage/form-elements.html#concept-meter-actual
  get _actualValue() {
    let candidate = 0;
 
    const value = this.getAttribute("value");
    if (value !== null) {
      const parsed = parseFloatingPointNumber(value);
      if (!Number.isNaN(parsed)) {
        candidate = parsed;
      }
    }
 
    const minimumValue = this._minimumValue;
    if (candidate < minimumValue) {
      return minimumValue;
    }
 
    const maximumValue = this._maximumValue;
    return candidate > maximumValue ? maximumValue : candidate;
  }
 
  // https://html.spec.whatwg.org/multipage/form-elements.html#concept-meter-low
  get _lowBoundary() {
    const minimumValue = this._minimumValue;
    let candidate = minimumValue;
 
    const low = this.getAttribute("low");
    if (low !== null) {
      const parsed = parseFloatingPointNumber(low);
      if (!Number.isNaN(parsed)) {
        candidate = parsed;
      }
    }
 
    if (candidate < minimumValue) {
      return minimumValue;
    }
 
    const maximumValue = this._maximumValue;
    return candidate > maximumValue ? maximumValue : candidate;
  }
 
  // https://html.spec.whatwg.org/multipage/form-elements.html#concept-meter-high
  get _highBoundary() {
    const maximumValue = this._maximumValue;
    let candidate = maximumValue;
 
    const high = this.getAttribute("high");
    if (high !== null) {
      const parsed = parseFloatingPointNumber(high);
      if (!Number.isNaN(parsed)) {
        candidate = parsed;
      }
    }
 
    const lowBoundary = this._lowBoundary;
    if (candidate < lowBoundary) {
      return lowBoundary;
    }
 
    return candidate > maximumValue ? maximumValue : candidate;
  }
 
  // https://html.spec.whatwg.org/multipage/form-elements.html#concept-meter-optimum
  get _optimumPoint() {
    const minimumValue = this._minimumValue;
    const maximumValue = this._maximumValue;
    let candidate = (minimumValue + maximumValue) / 2;
 
    const optimum = this.getAttribute("optimum");
    if (optimum !== null) {
      const parsed = parseFloatingPointNumber(optimum);
      if (!Number.isNaN(parsed)) {
        candidate = parsed;
      }
    }
 
    if (candidate < minimumValue) {
      return minimumValue;
    }
 
    return candidate > maximumValue ? maximumValue : candidate;
  }
 
  get labels() {
    return getLabelsForLabelable(this);
  }
 
  get value() {
    return this._actualValue;
  }
 
  set value(val) {
    this.setAttribute("value", String(val));
  }
 
  get min() {
    return this._minimumValue;
  }
 
  set min(val) {
    this.setAttribute("min", String(val));
  }
 
  get max() {
    return this._maximumValue;
  }
 
  set max(val) {
    this.setAttribute("max", String(val));
  }
 
  get low() {
    return this._lowBoundary;
  }
 
  set low(val) {
    this.setAttribute("low", String(val));
  }
 
  get high() {
    return this._highBoundary;
  }
 
  set high(val) {
    this.setAttribute("high", String(val));
  }
 
  get optimum() {
    return this._optimumPoint;
  }
 
  set optimum(val) {
    this.setAttribute("optimum", String(val));
  }
}
 
module.exports = {
  implementation: HTMLMeterElementImpl
};