Skip to content

components option should support readonly object #4062

@xiaoping0x

Description

@xiaoping0x

Vue.js version

2.0.0

Reproduction Link

Steps to reproduce

// components/index.js export Foo, Bar etc.
import * as components from './components';

export default {
  name: 'app',
  components
};

What is Expected?

Show ok without errors.

What is actually happening?

Browser throw error components has only getter.

Reasons

function normalizeComponents (options) {
  if (options.components) {
    var components = options.components;
    var def;
    for (var key in components) {
      var lower = key.toLowerCase();
      if (isBuiltInTag(lower) || config.isReservedTag(lower)) {
        "development" !== 'production' && warn(
          'Do not use built-in or reserved HTML elements as component ' +
          'id: ' + key
        );
        continue
      }
      def = components[key];
      if (isPlainObject(def)) {
        // should create or clone new components object inside Vue
        // instead of old one
        components[key] = Vue$3.extend(def);
      }
    }
  }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions