From 6cd0258fb62a00272c909d3628dfbdfd720a9f67 Mon Sep 17 00:00:00 2001 From: Jen Weber Date: Sat, 2 Feb 2019 12:24:53 -0500 Subject: [PATCH] [BUGFIX lts] support numbers in component names for Angle Brackets Previously, c3-plot would not work when invoked as . Now it will resolve correctly. Closes #17549 --- .../lib/system/dasherize-component-name.ts | 2 +- .../tests/system/dasherize-component-name-test.js | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/ember-template-compiler/lib/system/dasherize-component-name.ts b/packages/ember-template-compiler/lib/system/dasherize-component-name.ts index 2c7389545af..beb1139edf4 100644 --- a/packages/ember-template-compiler/lib/system/dasherize-component-name.ts +++ b/packages/ember-template-compiler/lib/system/dasherize-component-name.ts @@ -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(1000, key => key.replace(SIMPLE_DASHERIZE_REGEXP, (char, index) => { if (index === 0 || !ALPHA.test(key[index - 1])) { diff --git a/packages/ember-template-compiler/tests/system/dasherize-component-name-test.js b/packages/ember-template-compiler/tests/system/dasherize-component-name-test.js index c57ae33a1dc..75a045ec019 100644 --- a/packages/ember-template-compiler/tests/system/dasherize-component-name-test.js +++ b/packages/ember-template-compiler/tests/system/dasherize-component-name-test.js @@ -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');