Skip to content

Commit

Permalink
keep consistency in dev and prod env (#4093)
Browse files Browse the repository at this point in the history
* keep consistency in dev and prod env

* Update extend.js

* delete name=null

* fixup

* Update name.spec.js
  • Loading branch information
jingsam authored and yyx990803 committed Nov 4, 2016
1 parent 4078ce9 commit c23c5c5
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 10 deletions.
3 changes: 1 addition & 2 deletions src/core/global-api/extend.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,13 @@ export function initExtend (Vue: GlobalAPI) {
if (isFirstExtend && 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 (!/^[a-zA-Z][\w-]*$/.test(name)) {
warn(
'Invalid component name: "' + name + '". Component names ' +
'can only contain alphanumeric characaters and the hyphen.'
)
name = null
}
}
const Sub = function VueComponent (options) {
Expand Down
8 changes: 0 additions & 8 deletions test/unit/features/options/name.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,6 @@ describe('Options name', () => {
/* 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', () => {
const SuperComponent = Vue.component('super-component', {
name: 'SuperVue'
Expand Down

0 comments on commit c23c5c5

Please sign in to comment.