Просмотр исходного кода

support config.ignoredElements

Evan You 10 лет назад
Родитель
Сommit
f2419a73b9
2 измененных файлов с 17 добавлено и 5 удалено
  1. 6 0
      src/core/config.js
  2. 11 5
      src/core/vdom/create-element.js

+ 6 - 0
src/core/config.js

@@ -6,6 +6,7 @@ export type Config = {
   optionMergeStrategies: { [key: string]: Function },
   silent: boolean,
   errorHandler: ?Function,
+  ignoredElements: ?Array<string>,
   isReservedTag: (x?: string) => boolean,
   isUnknownElement: (x?: string) => boolean,
   mustUseProp: (x?: string) => boolean,
@@ -32,6 +33,11 @@ const config: Config = {
    */
   errorHandler: null,
 
+  /**
+   * Ignore certain custom elements
+   */
+  ignoredElements: null,
+
   /**
    * Check if a tag is reserved so that it cannot be registered as a
    * component. This is platform-dependent and may be overwritten.

+ 11 - 5
src/core/vdom/create-element.js

@@ -53,14 +53,19 @@ export function renderElement (
     let Ctor
     if (config.isReservedTag(tag)) {
       return new VNode(
-        tag, data, undefined,
-        undefined, undefined, namespace, context, host
+        tag, data,
+        undefined, undefined, undefined,
+        namespace, context, host
       )
     } else if ((Ctor = resolveAsset(context.$options, 'components', tag))) {
       return createComponent(Ctor, data, parent, context, host, tag)
     } else {
       if (process.env.NODE_ENV !== 'production') {
-        if (!namespace && config.isUnknownElement(tag)) {
+        if (
+          !namespace &&
+          !(config.ignoredElements && config.ignoredElements.indexOf(tag) > -1) &&
+          config.isUnknownElement(tag)
+        ) {
           warn(
             'Unknown custom element: <' + tag + '> - did you ' +
             'register the component correctly? For recursive components, ' +
@@ -69,8 +74,9 @@ export function renderElement (
         }
       }
       return new VNode(
-        tag, data, undefined,
-        undefined, undefined, namespace, context, host
+        tag, data,
+        undefined, undefined, undefined,
+        namespace, context, host
       )
     }
   } else {