Skip to content

Commit 254858a

Browse files
committed
component syntax type -> is
1 parent 59cf0cc commit 254858a

File tree

8 files changed

+36
-36
lines changed

8 files changed

+36
-36
lines changed

component.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
"src/util/index.js",
7272
"src/util/lang.js",
7373
"src/util/merge-option.js",
74+
"src/util/misc.js",
7475
"src/vue.js",
7576
"src/watcher.js"
7677
]

src/util/index.js

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,4 @@ extend(exports, require('./env'))
66
extend(exports, require('./dom'))
77
extend(exports, require('./filter'))
88
extend(exports, require('./debug'))
9-
10-
/**
11-
* Check if an element is a component, if yes return its
12-
* component id.
13-
*
14-
* @param {Element} el
15-
* @param {Object} options
16-
* @return {String|undefined}
17-
*/
18-
19-
exports.checkComponent = function (el, options) {
20-
var tag = el.tagName.toLowerCase()
21-
if (options.components[tag]) {
22-
return tag
23-
}
24-
// dynamic syntax
25-
if (tag === 'component') {
26-
var exp = el.getAttribute('type')
27-
el.removeAttribute('type')
28-
return exp
29-
}
30-
}
9+
extend(exports, require('./misc'))

src/util/misc.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* Check if an element is a component, if yes return its
3+
* component id.
4+
*
5+
* @param {Element} el
6+
* @param {Object} options
7+
* @return {String|undefined}
8+
*/
9+
10+
exports.checkComponent = function (el, options) {
11+
var tag = el.tagName.toLowerCase()
12+
if (tag === 'component') {
13+
// dynamic syntax
14+
var exp = el.getAttribute('is')
15+
el.removeAttribute('is')
16+
return exp
17+
} else if (options.components[tag]) {
18+
return tag
19+
}
20+
}

test/unit/specs/async_component_spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ describe('Async components', function () {
4040
it('dynamic', function (done) {
4141
var vm = new Vue({
4242
el: el,
43-
template: '<component type="{{view}}"></component>',
43+
template: '<component is="{{view}}"></component>',
4444
data: {
4545
view: 'a'
4646
},
@@ -84,7 +84,7 @@ describe('Async components', function () {
8484
it('invalidate pending on dynamic switch', function (done) {
8585
var vm = new Vue({
8686
el: el,
87-
template: '<component type="{{view}}"></component>',
87+
template: '<component is="{{view}}"></component>',
8888
data: {
8989
view: 'a'
9090
},
@@ -277,7 +277,7 @@ describe('Async components', function () {
277277
it('warn when used with dynamic v-repeat', function () {
278278
var vm = new Vue({
279279
el: el,
280-
template: '<component v-repeat="list" type="{{c}}"></component>',
280+
template: '<component v-repeat="list" is="{{c}}"></component>',
281281
data: {
282282
list: [1, 2, 3],
283283
c: 'test'

test/unit/specs/directives/component_spec.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ if (_.inBrowser) {
8787
it('dynamic', function (done) {
8888
var vm = new Vue({
8989
el: el,
90-
template: '<component type="{{view}}" v-attr="view:view"></component>',
90+
template: '<component is="{{view}}" v-attr="view:view"></component>',
9191
data: {
9292
view: 'a'
9393
},
@@ -125,7 +125,7 @@ if (_.inBrowser) {
125125
var spyB = jasmine.createSpy()
126126
var vm = new Vue({
127127
el: el,
128-
template: '<component type="{{view}}" keep-alive></component>',
128+
template: '<component is="{{view}}" keep-alive></component>',
129129
data: {
130130
view: 'a'
131131
},
@@ -252,7 +252,7 @@ if (_.inBrowser) {
252252
data: {
253253
view: 'a'
254254
},
255-
template: '<component type="{{view}}" wait-for="ok"></component>',
255+
template: '<component is="{{view}}" wait-for="ok"></component>',
256256
components: {
257257
a: {
258258
template: 'AAA'
@@ -282,7 +282,7 @@ if (_.inBrowser) {
282282
data: {
283283
view: 'a'
284284
},
285-
template: '<component type="{{view}}" v-transition="test" transition-mode="in-out"></component>',
285+
template: '<component is="{{view}}" v-transition="test" transition-mode="in-out"></component>',
286286
components: {
287287
a: { template: 'AAA' },
288288
b: { template: 'BBB' }
@@ -322,7 +322,7 @@ if (_.inBrowser) {
322322
data: {
323323
view: 'a'
324324
},
325-
template: '<component type="{{view}}" v-transition="test" transition-mode="out-in"></component>',
325+
template: '<component is="{{view}}" v-transition="test" transition-mode="out-in"></component>',
326326
components: {
327327
a: { template: 'AAA' },
328328
b: { template: 'BBB' }
@@ -356,7 +356,7 @@ if (_.inBrowser) {
356356
it('teardown', function (done) {
357357
var vm = new Vue({
358358
el: el,
359-
template: '<component type="{{view}}" keep-alive></component>',
359+
template: '<component is="{{view}}" keep-alive></component>',
360360
data: {
361361
view: 'test'
362362
},

test/unit/specs/directives/if_spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ if (_.inBrowser) {
116116
ok: false,
117117
view: 'a'
118118
},
119-
template: '<component type="{{view}}" v-if="ok"></component>',
119+
template: '<component is="{{view}}" v-if="ok"></component>',
120120
components: {
121121
a: {
122122
template: 'AAA'

test/unit/specs/directives/ref_spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ if (_.inBrowser) {
3434
el: el,
3535
components: components,
3636
data: { test: 'test' },
37-
template: '<component type="{{test}}" v-ref="test"></component>'
37+
template: '<component is="{{test}}" v-ref="test"></component>'
3838
})
3939
expect(vm.$.test.$options.id).toBe('test')
4040
vm.test = 'test2'
@@ -52,7 +52,7 @@ if (_.inBrowser) {
5252
var vm = new Vue({
5353
el: el,
5454
data: { view: 'test1' },
55-
template: '<component type="{{view}}"></component>',
55+
template: '<component is="{{view}}"></component>',
5656
components: {
5757
test1: {
5858
id: 'test1',

test/unit/specs/directives/repeat_spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ if (_.inBrowser) {
254254
it('dynamic component type based on instance data', function () {
255255
var vm = new Vue({
256256
el: el,
257-
template: '<component v-repeat="list" type="view-{{type}}"></component>',
257+
template: '<component v-repeat="list" is="view-{{type}}"></component>',
258258
data: {
259259
list: [
260260
{ type: 'a' },
@@ -278,7 +278,7 @@ if (_.inBrowser) {
278278
// #458 meta properties
279279
vm = new Vue({
280280
el: el,
281-
template: '<component v-repeat="list" type="view-{{$value}}"></component>',
281+
template: '<component v-repeat="list" is="view-{{$value}}"></component>',
282282
data: {
283283
list: ['a', 'b', 'c']
284284
},

0 commit comments

Comments
 (0)