diff --git a/csharp/tests/Facebook.Yoga/YGDisplayTest.cs b/csharp/tests/Facebook.Yoga/YGDisplayTest.cs index 6a35d597..237686ba 100644 --- a/csharp/tests/Facebook.Yoga/YGDisplayTest.cs +++ b/csharp/tests/Facebook.Yoga/YGDisplayTest.cs @@ -213,8 +213,6 @@ namespace Facebook.Yoga root_child1_child0.FlexShrink = 1; root_child1_child0.FlexBasis = 0.Percent(); root_child1_child0.Width = 20; - root_child1_child0.MinWidth = 0; - root_child1_child0.MinHeight = 0; root_child1.Insert(0, root_child1_child0); YogaNode root_child2 = new YogaNode(config); diff --git a/gentest/gentest.js b/gentest/gentest.js index 4dd4eaea..66a1da8e 100755 --- a/gentest/gentest.js +++ b/gentest/gentest.js @@ -137,7 +137,7 @@ function checkDefaultValues() { {style:'bottom', value:'undefined'}, {style:'display', value:'flex'}, ].forEach(function(item) { - assert(item.value === getDefaultStyleValue(item.style), + assert(isDefaultStyleValue(item.style, item.value), item.style + ' should be ' + item.value); }); } @@ -156,9 +156,11 @@ function setupTestTree(e, parent, node, genericNode, nodeName, parentName, index style == 'width' || style == 'height')) { continue; - } - if (node.style[style] !== getDefaultStyleValue(style)) { + + var DEFAULT_STYLES = Object.create } + + if (!isDefaultStyleValue(style, node.style[style])) { switch (style) { case 'direction': e.YGNodeStyleSetDirection(nodeName, directionValue(e, node.style[style])); @@ -399,21 +401,38 @@ function displayValue(e, value){ } } -function getDefaultStyleValue(style) { - if (style == 'position') { - return 'relative'; +var DEFAULT_STYLES = new Map(); + +function isDefaultStyleValue(style, value) { + let defaultStyle = DEFAULT_STYLES.get(style); + if (defaultStyle == null) { + switch (style) { + case 'position': + defaultStyle = new Set(['relative']);; + break; + + case 'left': + case 'top': + case 'right': + case 'bottom': + case 'start': + case 'end': + defaultStyle = new Set(['undefined']); + break; + + case 'min-height': + case 'min-width': + defaultStyle = new Set(['0', '0px', 'auto']); + break; + + default: + var node = document.getElementById('default'); + defaultStyle = new Set([getComputedStyle(node, null)[style]]); + break; + } + DEFAULT_STYLES.set(style, defaultStyle); } - switch (style) { - case 'left': - case 'top': - case 'right': - case 'bottom': - case 'start': - case 'end': - return 'undefined'; - } - var node = document.getElementById('default'); - return getComputedStyle(node, null).getPropertyValue(style); + return DEFAULT_STYLES.get(style).has(value); } function getRoundedSize(node) { diff --git a/java/tests/com/facebook/yoga/YGDisplayTest.java b/java/tests/com/facebook/yoga/YGDisplayTest.java index 0671d28e..38bf5193 100644 --- a/java/tests/com/facebook/yoga/YGDisplayTest.java +++ b/java/tests/com/facebook/yoga/YGDisplayTest.java @@ -218,8 +218,6 @@ public class YGDisplayTest { root_child1_child0.setFlexShrink(1f); root_child1_child0.setFlexBasisPercent(0f); root_child1_child0.setWidth(20f); - root_child1_child0.setMinWidth(0f); - root_child1_child0.setMinHeight(0f); root_child1.addChildAt(root_child1_child0, 0); final YogaNode root_child2 = createNode(config); diff --git a/javascript/tests/Facebook.Yoga/YGDisplayTest.js b/javascript/tests/Facebook.Yoga/YGDisplayTest.js index 356a1aa7..e5be4a55 100644 --- a/javascript/tests/Facebook.Yoga/YGDisplayTest.js +++ b/javascript/tests/Facebook.Yoga/YGDisplayTest.js @@ -215,8 +215,6 @@ it("display_none_with_child", function () { root_child1_child0.setFlexShrink(1); root_child1_child0.setFlexBasis("0%"); root_child1_child0.setWidth(20); - root_child1_child0.setMinWidth(0); - root_child1_child0.setMinHeight(0); root_child1.insertChild(root_child1_child0, 0); var root_child2 = Yoga.Node.create(config); diff --git a/tests/YGDisplayTest.cpp b/tests/YGDisplayTest.cpp index 52ff9cc8..97a9e9f8 100644 --- a/tests/YGDisplayTest.cpp +++ b/tests/YGDisplayTest.cpp @@ -206,8 +206,6 @@ TEST(YogaTest, display_none_with_child) { YGNodeStyleSetFlexShrink(root_child1_child0, 1); YGNodeStyleSetFlexBasisPercent(root_child1_child0, 0); YGNodeStyleSetWidth(root_child1_child0, 20); - YGNodeStyleSetMinWidth(root_child1_child0, 0); - YGNodeStyleSetMinHeight(root_child1_child0, 0); YGNodeInsertChild(root_child1, root_child1_child0, 0); const YGNodeRef root_child2 = YGNodeNewWithConfig(config);