FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

lower-case-dashed components css support fixed by enchev · Pull Request #994 · NativeScript/NativeScript · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .css  (1) .ts  (2) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
4 changes: 4 additions & 0 deletions apps/tests/xml-declaration/custom-css-file.css
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
.MyClass {
background-color: green;
}

stack-layout {
background-color: green;
}
17 changes: 17 additions & 0 deletions apps/tests/xml-declaration/xml-declaration-tests.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,23 @@ export function test_parse_ShouldResolveExportsFromCodeFileForTemplates() {
}
}

export function test_parse_css_is_applied_by_type_to_lower_case_dashed_components() {
var newPage: Page;
var pageFactory = function (): Page {
newPage = <Page>builder.parse("<page cssFile='~/xml-declaration/custom-css-file.css'><stack-layout /></page>");
return newPage;
};

helper.navigate(pageFactory);
TKUnit.assert(newPage.isLoaded, "The page should be loaded here.");
try {
helper.assertViewBackgroundColor(newPage.content, "#008000");
}
finally {
helper.goBack();
}
};

export function test_parse_ShouldApplyCssFromCssFile() {
var newPage: Page;
var pageFactory = function (): Page {
Expand Down
9 changes: 7 additions & 2 deletions ui/styling/css-selector.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,15 @@ class CssTypeSelector extends CssSelector {
return TYPE_SPECIFICITY;
}
public matches(view: view.View): boolean {
return this.expression.toLowerCase() === view.typeName.toLowerCase();
return matchesType(this.expression, view);
}
}

function matchesType(expression: string, view: view.View): boolean {
return expression.toLowerCase() === view.typeName.toLowerCase() ||
expression.toLowerCase() === view.typeName.split(/(?=[A-Z])/).join("-").toLowerCase();
}

class CssIdSelector extends CssSelector {
get specificity(): number {
return ID_SPECIFICITY;
Expand Down Expand Up @@ -150,7 +155,7 @@ export class CssVisualStateSelector extends CssSelector {
}

if (this._isByType) {
matches = this._match === view.cssType.toLowerCase();
matches = matchesType(this._match, view);
}

return matches;
Expand Down

Back | FazBrowse Home | New Git URL