MCPcopy
hub / github.com/css/csso / add

Method add

lib/restructure/4-restructShorthand.js:160–251  ·  view source on GitHub ↗
(name, declaration)

Source from the content-addressed store, hash-verified

158 }
159
160 add(name, declaration) {
161 function attemptToAdd() {
162 const sides = this.sides;
163 const side = SIDE[name];
164
165 if (side) {
166 if (side in sides === false) {
167 return false;
168 }
169
170 const values = this.getValueSequence(declaration, 1);
171
172 if (!values || !values.length) {
173 return false;
174 }
175
176 // can mix only if specials are equal
177 for (const key in sides) {
178 if (sides[key] !== null && sides[key].special !== values[0].special) {
179 return false;
180 }
181 }
182
183 if (!this.canOverride(side, values[0])) {
184 return true;
185 }
186
187 sides[side] = values[0];
188
189 return true;
190 } else if (name === this.name) {
191 const values = this.getValueSequence(declaration, 4);
192
193 if (!values || !values.length) {
194 return false;
195 }
196
197 switch (values.length) {
198 case 1:
199 values[RIGHT] = values[TOP];
200 values[BOTTOM] = values[TOP];
201 values[LEFT] = values[TOP];
202 break;
203
204 case 2:
205 values[BOTTOM] = values[TOP];
206 values[LEFT] = values[RIGHT];
207 break;
208
209 case 3:
210 values[LEFT] = values[RIGHT];
211 break;
212 }
213
214 // can mix only if specials are equal
215 for (let i = 0; i < 4; i++) {
216 for (const key in sides) {
217 if (sides[key] !== null && sides[key].special !== values[i].special) {

Callers 2

processRuleFunction · 0.80
processSelectorFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected