Skip to content

Commit 7ab29d9

Browse files
committed
fix: normalizeToNamedBlockName util
1 parent 966b1bd commit 7ab29d9

File tree

3 files changed

+3
-29
lines changed

3 files changed

+3
-29
lines changed

src/utils/normalizers.ts

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,24 +24,6 @@ export function normalizeToAngleBracketComponent(name: string) {
2424
});
2525
}
2626

27-
export function normalizeToNamedBlockName(name: string) {
28-
const SIMPLE_DASHERIZE_REGEXP = /[a-z]|\/|-/g;
29-
const ALPHA = /[A-Za-z0-9]/;
30-
31-
if (name.includes('.')) {
32-
return name;
33-
}
34-
35-
return name.replace(SIMPLE_DASHERIZE_REGEXP, (char, index) => {
36-
if (index !== 0 && !ALPHA.test(name[index - 1])) {
37-
return char.toUpperCase();
38-
}
39-
40-
// Remove all occurrences of '-'s from the name that aren't starting with `-`
41-
return char === '-' ? '' : char.toLowerCase();
42-
});
43-
}
44-
4527
// https://github.com/rwjblue/ember-angle-bracket-invocation-polyfill/blob/master/lib/ast-transform.js#L33
4628
export function normalizeToClassicComponent(rawName: string) {
4729
const name = rawName.split('$').pop() || '';

src/utils/template-tokens-collector.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { preprocess, traverse, ASTv1 } from '@glimmer/syntax';
2-
import { normalizeToClassicComponent, normalizeToNamedBlockName } from './normalizers';
2+
import { normalizeToClassicComponent } from './normalizers';
33

44
function tokensFromType(node: ASTv1.BaseNode, scopedTokens: string[]) {
55
const tokensMap = {
@@ -126,7 +126,7 @@ export function getTemplateBlocks(html: string): string[] {
126126
},
127127
});
128128

129-
return Array.from(tokensSet).map((el) => normalizeToNamedBlockName(el));
129+
return Array.from(tokensSet);
130130
}
131131

132132
function getTemplateTokens(ast: ASTv1.Template, nativeTokens: string[]) {

test/utils/normalizers-test.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { normalizeToAngleBracketComponent, normalizeToNamedBlockName, normalizeToClassicComponent, normalizeServiceName } from '../../src/utils/normalizers';
1+
import { normalizeToAngleBracketComponent, normalizeToClassicComponent, normalizeServiceName } from '../../src/utils/normalizers';
22

33
describe('normalizeServiceName', () => {
44
it('able to convert service to path', () => {
@@ -27,14 +27,6 @@ describe('normalizeToClassicComponent', () => {
2727
});
2828
});
2929

30-
describe('normalizeToNamedBlockName', () => {
31-
it('able to convert dasherized blocks to camel-case', () => {
32-
expect(normalizeToNamedBlockName('foo')).toEqual('foo');
33-
expect(normalizeToNamedBlockName('foo-bar')).toEqual('fooBar');
34-
expect(normalizeToNamedBlockName('fooBar')).toEqual('fooBar');
35-
});
36-
});
37-
3830
describe('normalizeToAngleBracketComponent', () => {
3931
it('able to convert path to angle brackets', () => {
4032
expect(normalizeToAngleBracketComponent('-foo')).toEqual('-Foo');

0 commit comments

Comments
 (0)