Skip to content
Merged
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
18 changes: 0 additions & 18 deletions src/utils/normalizers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,6 @@ export function normalizeToAngleBracketComponent(name: string) {
});
}

export function normalizeToNamedBlockName(name: string) {
const SIMPLE_DASHERIZE_REGEXP = /[a-z]|\/|-/g;
const ALPHA = /[A-Za-z0-9]/;

if (name.includes('.')) {
return name;
}

return name.replace(SIMPLE_DASHERIZE_REGEXP, (char, index) => {
if (index !== 0 && !ALPHA.test(name[index - 1])) {
return char.toUpperCase();
}

// Remove all occurrences of '-'s from the name that aren't starting with `-`
return char === '-' ? '' : char.toLowerCase();
});
}

// https://github.com/rwjblue/ember-angle-bracket-invocation-polyfill/blob/master/lib/ast-transform.js#L33
export function normalizeToClassicComponent(rawName: string) {
const name = rawName.split('$').pop() || '';
Expand Down
4 changes: 2 additions & 2 deletions src/utils/template-tokens-collector.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { preprocess, traverse, ASTv1 } from '@glimmer/syntax';
import { normalizeToClassicComponent, normalizeToNamedBlockName } from './normalizers';
import { normalizeToClassicComponent } from './normalizers';

function tokensFromType(node: ASTv1.BaseNode, scopedTokens: string[]) {
const tokensMap = {
Expand Down Expand Up @@ -126,7 +126,7 @@ export function getTemplateBlocks(html: string): string[] {
},
});

return Array.from(tokensSet).map((el) => normalizeToNamedBlockName(el));
return Array.from(tokensSet);
}

function getTemplateTokens(ast: ASTv1.Template, nativeTokens: string[]) {
Expand Down
10 changes: 1 addition & 9 deletions test/utils/normalizers-test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { normalizeToAngleBracketComponent, normalizeToNamedBlockName, normalizeToClassicComponent, normalizeServiceName } from '../../src/utils/normalizers';
import { normalizeToAngleBracketComponent, normalizeToClassicComponent, normalizeServiceName } from '../../src/utils/normalizers';

describe('normalizeServiceName', () => {
it('able to convert service to path', () => {
Expand Down Expand Up @@ -27,14 +27,6 @@ describe('normalizeToClassicComponent', () => {
});
});

describe('normalizeToNamedBlockName', () => {
it('able to convert dasherized blocks to camel-case', () => {
expect(normalizeToNamedBlockName('foo')).toEqual('foo');
expect(normalizeToNamedBlockName('foo-bar')).toEqual('fooBar');
expect(normalizeToNamedBlockName('fooBar')).toEqual('fooBar');
});
});

describe('normalizeToAngleBracketComponent', () => {
it('able to convert path to angle brackets', () => {
expect(normalizeToAngleBracketComponent('-foo')).toEqual('-Foo');
Expand Down
Loading