MCPcopy Create free account
hub / github.com/NativeScript/NativeScript / equalsCommon

Function equalsCommon

packages/core/ui/styling/length-shared.ts:10–36  ·  view source on GitHub ↗
(a: CoreTypes.PercentLengthType, b: CoreTypes.PercentLengthType)

Source from the content-addressed store, hash-verified

8function equalsCommon(a: CoreTypes.LengthType, b: CoreTypes.LengthType): boolean;
9function equalsCommon(a: CoreTypes.PercentLengthType, b: CoreTypes.PercentLengthType): boolean;
10function equalsCommon(a: CoreTypes.PercentLengthType, b: CoreTypes.PercentLengthType): boolean {
11 if (a == 'auto' || isCssWideKeyword(a)) {
12 return b == 'auto' || isCssWideKeyword(b);
13 }
14
15 if (b == 'auto' || isCssWideKeyword(b)) {
16 return false;
17 }
18
19 if (typeof a === 'number') {
20 if (typeof b === 'number') {
21 return a == b;
22 }
23 if (!b) {
24 return false;
25 }
26 return (b as CoreTypes.LengthDipUnit).unit == 'dip' && a == (b as CoreTypes.LengthDipUnit).value;
27 }
28
29 if (typeof b === 'number') {
30 return a ? (a as CoreTypes.LengthDipUnit).unit == 'dip' && (a as CoreTypes.LengthDipUnit).value == b : false;
31 }
32 if (!a || !b) {
33 return false;
34 }
35 return (a as CoreTypes.LengthDipUnit).value == (b as CoreTypes.LengthDipUnit).value && (a as CoreTypes.LengthDipUnit).unit == (b as CoreTypes.LengthDipUnit).unit;
36}
37
38function convertToStringCommon(length: CoreTypes.LengthType | CoreTypes.PercentLengthType): string {
39 if (length == 'auto' || isCssWideKeyword(length)) {

Callers

nothing calls this directly

Calls 1

isCssWideKeywordFunction · 0.90

Tested by

no test coverage detected