Skip to content

Commit

Permalink
feat(registry): allow overriding elements (#626)
Browse files Browse the repository at this point in the history
* feat: allow override of registerElement

* fix: log when element was already registered
  • Loading branch information
farfromrefug committed Apr 9, 2020
1 parent b502fc8 commit e37788c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion platform/nativescript/element-registry.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as builtInComponents from './runtime/components'
import { trace } from './util'

const elementMap = {}
const nativeRegExp = /Native/gi
Expand All @@ -25,8 +26,11 @@ export function registerElement(elementName, resolver, meta) {

meta = Object.assign({}, defaultViewMeta, meta)

// allow override of elements classes (N ones especially)
// this is very practical in case you want to test new component
// or simply override the global Button for example
if (elementMap[normalizedName]) {
throw new Error(`Element for ${elementName} already registered.`)
trace(`Element for ${elementName} already registered.`)
}

if (!meta.component) {
Expand Down

0 comments on commit e37788c

Please sign in to comment.