Skip to content

Commit

Permalink
[BUGFIX lts] support numbers in component names for Angle Brackets
Browse files Browse the repository at this point in the history
Previously, c3-plot would not work when invoked as <C3Plot />.
Now it will resolve correctly.
Closes #17549

(cherry picked from commit 6cd0258)
  • Loading branch information
jenweber authored and kategengler committed Feb 5, 2019
1 parent 38b9060 commit f485ad5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Cache } from '@ember/-internals/utils';
`Ember.String.dasherize` would resolve it to `xfoo`..
*/
const SIMPLE_DASHERIZE_REGEXP = /[A-Z]/g;
const ALPHA = /[A-Za-z]/;
const ALPHA = /[A-Za-z0-9]/;
export default new Cache<string, string>(1000, key =>
key.replace(SIMPLE_DASHERIZE_REGEXP, (char, index) => {
if (index === 0 || !ALPHA.test(key[index - 1])) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ moduleFor(
assert.equal(COMPONENT_NAME_SIMPLE_DASHERIZE_CACHE.get('Foo'), 'foo');
assert.equal(COMPONENT_NAME_SIMPLE_DASHERIZE_CACHE.get('foo-bar'), 'foo-bar');
assert.equal(COMPONENT_NAME_SIMPLE_DASHERIZE_CACHE.get('FooBar'), 'foo-bar');
assert.equal(COMPONENT_NAME_SIMPLE_DASHERIZE_CACHE.get('F3Bar'), 'f3-bar');
assert.equal(COMPONENT_NAME_SIMPLE_DASHERIZE_CACHE.get('Foo3Bar'), 'foo3-bar');
assert.equal(COMPONENT_NAME_SIMPLE_DASHERIZE_CACHE.get('Foo3barBaz'), 'foo3bar-baz');
assert.equal(COMPONENT_NAME_SIMPLE_DASHERIZE_CACHE.get('FooB3ar'), 'foo-b3ar');
assert.equal(COMPONENT_NAME_SIMPLE_DASHERIZE_CACHE.get('XBlah'), 'x-blah');
assert.equal(COMPONENT_NAME_SIMPLE_DASHERIZE_CACHE.get('X-Blah'), 'x-blah');
assert.equal(COMPONENT_NAME_SIMPLE_DASHERIZE_CACHE.get('Foo::BarBaz'), 'foo::bar-baz');
Expand Down

0 comments on commit f485ad5

Please sign in to comment.