Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 34 additions & 1 deletion apps/automated/src/ui/styling/css-keywords-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export var test_value_Inherited_after_revert = function () {
TKUnit.assertEqual(btn.color.hex, '#FF0000', 'color property');
};

// TODO: Add missing inherit support for non-inherited properties
// A keyword set from code only releases the local value; see test_css_inherit_* for the stylesheet keyword.
export var test_value_after_inherit = function () {
let page = helper.getCurrentPage();
let btn = new Button();
Expand Down Expand Up @@ -130,3 +130,36 @@ export var test_value_Inherited_after_inherit = function () {
(btn as any).color = 'inherit';
TKUnit.assertEqual(btn.color.hex, '#FF0000', 'color property');
};

export var test_css_inherit_on_non_inherited_property = function () {
let page = helper.getCurrentPage();
let btn = new Button();
let testStack = new StackLayout();

page.css = 'StackLayout { background-color: #FF0000; margin-top: 7; } Button { background-color: inherit; margin-top: inherit; }';

page.content = testStack;
testStack.addChild(btn);

TKUnit.assertEqual(btn.backgroundColor.hex, '#FF0000', 'backgroundColor property');
TKUnit.assertEqual(btn.marginTop, 7, 'marginTop property');

testStack.backgroundColor = new Color('#0000FF');
testStack.marginTop = 3;
TKUnit.assertEqual(btn.backgroundColor.hex, '#0000FF', 'backgroundColor property follows the parent');
TKUnit.assertEqual(btn.marginTop, 3, 'marginTop property follows the parent');
};

export var test_css_inherit_on_shorthand = function () {
let page = helper.getCurrentPage();
let btn = new Button();
let testStack = new StackLayout();

page.css = 'StackLayout { border-color: #FF0000; } Button { border-color: inherit; }';

page.content = testStack;
testStack.addChild(btn);

TKUnit.assertEqual((<Color>btn.borderTopColor).hex, '#FF0000', 'borderTopColor property');
TKUnit.assertEqual((<Color>btn.borderLeftColor).hex, '#FF0000', 'borderLeftColor property');
};
Loading
Loading