Sfoglia il codice sorgente

keep consistency in dev and prod env (#4093)

* keep consistency in dev and prod env

* Update extend.js

* delete name=null

* fixup

* Update name.spec.js
jingsam 9 anni fa
parent
commit
c23c5c5d70

+ 1 - 2
src/core/global-api/extend.js

@@ -22,14 +22,13 @@ export function initExtend (Vue: GlobalAPI) {
     if (isFirstExtend && extendOptions._Ctor) {
     if (isFirstExtend && extendOptions._Ctor) {
       return extendOptions._Ctor
       return extendOptions._Ctor
     }
     }
-    let name = extendOptions.name || Super.options.name
+    const name = extendOptions.name || Super.options.name
     if (process.env.NODE_ENV !== 'production') {
     if (process.env.NODE_ENV !== 'production') {
       if (!/^[a-zA-Z][\w-]*$/.test(name)) {
       if (!/^[a-zA-Z][\w-]*$/.test(name)) {
         warn(
         warn(
           'Invalid component name: "' + name + '". Component names ' +
           'Invalid component name: "' + name + '". Component names ' +
           'can only contain alphanumeric characaters and the hyphen.'
           'can only contain alphanumeric characaters and the hyphen.'
         )
         )
-        name = null
       }
       }
     }
     }
     const Sub = function VueComponent (options) {
     const Sub = function VueComponent (options) {

+ 0 - 8
test/unit/features/options/name.spec.js

@@ -20,14 +20,6 @@ describe('Options name', () => {
     /* eslint-enable */
     /* eslint-enable */
   })
   })
 
 
-  it('when incorrect name given it should not contain itself in self components', () => {
-    const vm = Vue.extend({
-      name: 'Hyper*Vue'
-    })
-
-    expect(vm.options.components['Hyper*Vue']).toBeUndefined()
-  })
-
   it('id should not override given name when using Vue.component', () => {
   it('id should not override given name when using Vue.component', () => {
     const SuperComponent = Vue.component('super-component', {
     const SuperComponent = Vue.component('super-component', {
       name: 'SuperVue'
       name: 'SuperVue'