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

Function equalsCommon

packages/core/ui/styling/style-properties.ts:30–56  ·  view source on GitHub ↗
(a: CoreTypes.PercentLengthType, b: CoreTypes.PercentLengthType | CoreTypes.LengthDipUnit)

Source from the content-addressed store, hash-verified

28function equalsCommon(a: CoreTypes.LengthType, b: CoreTypes.LengthType): boolean;
29function equalsCommon(a: CoreTypes.PercentLengthType, b: CoreTypes.PercentLengthType): boolean;
30function equalsCommon(a: CoreTypes.PercentLengthType, b: CoreTypes.PercentLengthType | CoreTypes.LengthDipUnit): boolean {
31 if (a == 'auto' || isCssWideKeyword(a)) {
32 return b == 'auto' || isCssWideKeyword(b);
33 }
34
35 if (b == 'auto' || isCssWideKeyword(b)) {
36 return false;
37 }
38
39 if (typeof a === 'number') {
40 if (typeof b === 'number') {
41 return a == b;
42 }
43 if (!b) {
44 return false;
45 }
46 return (b as CoreTypes.LengthDipUnit).unit == 'dip' && a == (b as CoreTypes.LengthDipUnit).value;
47 }
48
49 if (typeof b === 'number') {
50 return a ? (a as CoreTypes.LengthDipUnit).unit == 'dip' && (a as CoreTypes.LengthDipUnit).value == b : false;
51 }
52 if (!a || !b) {
53 return false;
54 }
55 return (a as CoreTypes.LengthDipUnit).value == (b as CoreTypes.LengthDipUnit).value && (a as CoreTypes.LengthDipUnit).unit == (b as CoreTypes.LengthDipUnit).unit;
56}
57
58function convertToStringCommon(length: CoreTypes.LengthType | CoreTypes.PercentLengthType): string {
59 if (length == 'auto' || isCssWideKeyword(length)) {

Callers

nothing calls this directly

Calls 1

isCssWideKeywordFunction · 0.90

Tested by

no test coverage detected