Skip to content
This repository was archived by the owner on Oct 12, 2021. It is now read-only.

Commit 652f877

Browse files
authored
fix(AppShell): make CSS class selectors case insensitive (#65)
Fix #64
1 parent 6709381 commit 652f877

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

app-shell/src/app/shell-parser/node-matcher/css-node-matcher.spec.ts

+9
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,15 @@ describe('CssNodeMatcher', () => {
5959
expect(complexSelector.match(node)).toBe(true);
6060
});
6161

62+
it('should match case insensitive class selector', () => {
63+
const classSelector = CssSelector.parse('.DIALOG');
64+
const selector = new CssNodeMatcher(classSelector);
65+
expect(selector.match(node)).toBe(true);
66+
const complexClassSelector = CssSelector.parse('.dialog.modal--drop');
67+
const complexSelector = new CssNodeMatcher(complexClassSelector);
68+
expect(complexSelector.match(node)).toBe(true);
69+
});
70+
6271
it('should match element by id', () => {
6372
const idSelector = CssSelector.parse('#dialog-id');
6473
const selector = new CssNodeMatcher(idSelector);

app-shell/src/app/shell-parser/node-matcher/css-node-matcher.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ export class CssNodeMatcher extends NodeMatcher {
4848
if (!classAttr) {
4949
return false;
5050
}
51-
const classMap = classAttr.value.split(' ')
51+
const classMap = classAttr.value
52+
.toLowerCase().split(' ')
5253
.reduce((accum: any, val: string) => {
5354
accum[val] = true;
5455
return accum;

app-shell/src/app/shell-parser/shell-parser.spec.ts

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import {
22
beforeEach,
33
it,
4-
xit,
54
describe,
65
expect,
76
inject
@@ -131,7 +130,6 @@ describe('ShellParserImpl', () => {
131130
describe('parseDoc', () => {
132131

133132
it('should strip with default selector', (done: any) => {
134-
debugger;
135133
const mockScope = new MockWorkerScope();
136134
const parser = createMockedWorker(mockScope);
137135
const response = new MockResponse(prerenderedTemplate);

0 commit comments

Comments
 (0)