File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -11,8 +11,8 @@ interface CustomElement {
1111 */
1212export function register ( classObject : CustomElement ) : void {
1313 const name = classObject . name
14- . replace ( / ( [ a - z A - Z ] ) (? = [ A - Z ] ) / g, '$1- ' )
15- . replace ( / - E l e m e n t $ / , '' )
14+ . replace ( / ( [ A - Z ] [ a - z ] ) / g, '-$1 ' )
15+ . replace ( / ( ^ - | - E l e m e n t $ ) / , '' )
1616 . toLowerCase ( )
1717 if ( ! window . customElements . get ( name ) ) {
1818 // eslint-disable-next-line @typescript-eslint/ban-ts-comment
Original file line number Diff line number Diff line change @@ -21,13 +21,19 @@ describe('register', () => {
2121 } )
2222
2323 it ( 'dasherises class names' , ( ) => {
24- class ThisIsAnExampleOfADasherisedClassName { }
25- register ( ThisIsAnExampleOfADasherisedClassName )
26- expect ( window . customElements . get ( 'this-is-an-example-of-a- dasherised-class-name ' ) ) . to . equal (
27- ThisIsAnExampleOfADasherisedClassName
24+ class ThisIsAnExampleOfDasherisedClassNames { }
25+ register ( ThisIsAnExampleOfDasherisedClassNames )
26+ expect ( window . customElements . get ( 'this-is-an-example-of-dasherised-class-names ' ) ) . to . equal (
27+ ThisIsAnExampleOfDasherisedClassNames
2828 )
2929 } )
3030
31+ it ( 'will intuitively dasherize acryonyms' , ( ) => {
32+ class URLBar { }
33+ register ( URLBar )
34+ expect ( window . customElements . get ( 'url-bar' ) ) . to . equal ( URLBar )
35+ } )
36+
3137 it ( 'automatically drops the `Element` suffix' , ( ) => {
3238 class ASuffixedElement { }
3339 register ( ASuffixedElement )
You can’t perform that action at this time.
0 commit comments