Skip to content

Commit

Permalink
feat(register): optional name parameter (#453)
Browse files Browse the repository at this point in the history
* feat(register): optional name parameter

* test(register): optional name parameter
  • Loading branch information
redgeoff authored Aug 28, 2021
1 parent 36143ef commit 8072962
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/compiler/compiler.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const registerComponents = () => {
});

// Composition
compiler.registerComponent('app.EditThing', {
register('app.EditThing', {
component: 'WrappedComponent',
});

Expand Down
9 changes: 7 additions & 2 deletions src/compiler/register.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import compiler from './compiler';

const register = (component) => {
compiler.registerComponent(component.name, component);
const register = (componentOrName, component) => {
let name = componentOrName;
if (!component) {
component = componentOrName;
name = component.name;
}
compiler.registerComponent(name, component);
};

export default register;

0 comments on commit 8072962

Please sign in to comment.