Skip to content

Commit

Permalink
Rename elementType() into componentName()
Browse files Browse the repository at this point in the history
The element attribute used is called name and not type, also
in Vue components have a name attribute.
  • Loading branch information
tvdeyen committed Nov 6, 2020
1 parent 8b0572d commit 7bd4d7c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ export default {
}
```

You now have acces to the `page` prop and its `elements`. Also you have access to the `elementType()` method that you can use to dynamically render element components.
You now have acces to the `page` prop and its `elements`. Also you have access to the `componentName()` method that you can use to dynamically render element components.

```html
<template>
<div :class="page.page_layout">
<component
:is="elementType(element)"
:is="componentName(element)"
v-for="element in page.elements"
:key="element.id"
:element="element"
Expand Down
4 changes: 2 additions & 2 deletions src/mixins/__tests__/page.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const AlchemyPageComponent = {
template: `
<div class="alchemy-page">
<component
:is="elementType(element)"
:is="componentName(element)"
v-for="element in page.elements"
:key="element.id"
:element="element"
Expand Down Expand Up @@ -97,7 +97,7 @@ describe("Alchemy page mixin", () => {
})
})

describe("elementType", () => {
describe("componentName", () => {
describe("if element component has been registered", () => {
it("returns the component name", () => {
const component = shallowMount(AlchemyPageComponent, {
Expand Down
2 changes: 1 addition & 1 deletion src/mixins/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default {
},
},
methods: {
elementType(element) {
componentName(element) {
const name = element.name
if (this.$options.components[name]) {
return name
Expand Down

0 comments on commit 7bd4d7c

Please sign in to comment.