Skip to content

Commit

Permalink
feat(registry): allow overwriting elements with a flag
Browse files Browse the repository at this point in the history
  • Loading branch information
rigor789 committed Apr 20, 2020
1 parent 1ea0c3d commit d8d1972
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/runtime/src/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export interface NSVViewMeta {
remove(child: NSVElement, parent: NSVElement): void
}
model?: NSVModelDescriptor
overwriteExisting?: boolean
}

export interface NSVElementDescriptor {
Expand Down Expand Up @@ -76,7 +77,7 @@ export function registerElement(
const normalizedName = normalizeElementName(elementName)
const mergedMeta = Object.assign({}, defaultViewMeta, meta)

if (elementMap[normalizedName]) {
if (elementMap[normalizedName] && !mergedMeta.overwriteExisting) {
throw new Error(`Element for ${elementName} already registered.`)
}

Expand Down

0 comments on commit d8d1972

Please sign in to comment.