浏览代码

remove <content>

Evan You 10 年之前
父节点
当前提交
511539cfd1

+ 1 - 1
src/element-directives/index.js

@@ -1,2 +1,2 @@
-exports.slot = exports.content = require('./slot')
+exports.slot = require('./slot')
 exports.partial = require('./partial')

+ 3 - 16
src/element-directives/slot.js

@@ -12,12 +12,6 @@ module.exports = {
   priority: 1750,
 
   bind: function () {
-
-    this.isSlot = this.el.tagName === 'SLOT'
-    if (process.env.NODE_ENV !== 'production' && !this.isSlot) {
-      _.deprecation.CONTENT()
-    }
-
     var host = this.vm
     var raw = host.$options._content
     var content
@@ -25,13 +19,9 @@ module.exports = {
       this.fallback()
       return
     }
-
     var context = host._context
-    var selector = this.isSlot
-      ? this.param('name')
-      : this.param('select')
-
-    if (!selector) {
+    var slotName = this.param('name')
+    if (!slotName) {
       // Default content
       var self = this
       var compileDefaultContent = function () {
@@ -51,10 +41,7 @@ module.exports = {
         compileDefaultContent()
       }
     } else {
-      // select content
-      if (this.isSlot) {
-        selector = '[slot="' + selector + '"]'
-      }
+      var selector = '[slot="' + slotName + '"]'
       var nodes = raw.querySelectorAll(selector)
       if (nodes.length) {
         content = extractFragment(nodes, raw)

+ 0 - 1
test/unit/specs/api/child_spec.js

@@ -1,5 +1,4 @@
 var Vue = require('../../../../src/vue')
-var _ = Vue.util
 
 describe('Child API', function () {
 

+ 1 - 1
test/unit/specs/api/lifecycle_spec.js

@@ -259,7 +259,7 @@ if (_.inBrowser) {
           },
           components: {
             dialog: {
-              template: '<content>'
+              template: '<slot></slot>'
             }
           }
         }).$mount()

+ 2 - 2
test/unit/specs/compiler/compile_spec.js

@@ -475,7 +475,7 @@ if (_.inBrowser) {
         },
         components: {
           test: {
-            template: '<content></content>'
+            template: '<slot></slot>'
           }
         }
       })
@@ -500,7 +500,7 @@ if (_.inBrowser) {
         },
         components: {
           test: {
-            template: '<content></content>'
+            template: '<slot></slot>'
           }
         }
       })

+ 2 - 2
test/unit/specs/directives/component_spec.js

@@ -229,7 +229,7 @@ if (_.inBrowser) {
         template: '<test v-show="ok">{{message}}</test>',
         components: {
           test: {
-            template: '<div><content></content> {{message}}</div>',
+            template: '<div><slot></slot> {{message}}</div>',
             replace: true,
             data: function () {
               return {
@@ -260,7 +260,7 @@ if (_.inBrowser) {
         template: '<test v-if="ok">{{message}}</test>',
         components: {
           test: {
-            template: '<content></content> {{message}}',
+            template: '<slot></slot> {{message}}',
             data: function () {
               return {
                 message: 'world'

+ 3 - 3
test/unit/specs/directives/if_spec.js

@@ -186,7 +186,7 @@ if (_.inBrowser) {
         template: '<outer><transcluded></transcluded></outer>',
         components: {
           outer: {
-            template: '<div v-if="$parent.show"><content></content></div>'
+            template: '<div v-if="$parent.show"><slot></slot></div>'
           },
           transcluded: {
             template: 'transcluded',
@@ -230,7 +230,7 @@ if (_.inBrowser) {
           outer: {
             template:
               '<div v-if="$parent.show">' +
-                '<content></content>' +
+                '<slot></slot>' +
               '</div>' +
               // this is to test that compnents that are not in the if block
               // should not fire attach/detach when v-if toggles
@@ -380,7 +380,7 @@ if (_.inBrowser) {
         template: '<parent><child v-if="show"></child></parent>',
         components: {
           parent: {
-            template: '<content></content>',
+            template: '<slot></slot>',
             created: function () {
               parentA = this
             }

+ 1 - 1
test/unit/specs/misc_spec.js

@@ -41,7 +41,7 @@ describe('Misc', function () {
       el: el,
       components: {
         outer: {
-          template: '<content></content>'
+          template: '<slot></slot>'
         },
         inner: {
           template: 'hi',