Browse Source

slots should have highest compilation priority (fix #2163)

Evan You 10 years ago
parent
commit
7fd665ff83
2 changed files with 24 additions and 1 deletions
  1. 1 1
      src/directives/priorities.js
  2. 23 0
      test/unit/specs/misc_spec.js

+ 1 - 1
src/directives/priorities.js

@@ -5,6 +5,6 @@ export const TRANSITION = 1100
 export const EL = 1500
 export const COMPONENT = 1500
 export const PARTIAL = 1750
-export const SLOT = 1750
 export const FOR = 2000
 export const IF = 2000
+export const SLOT = 2100

+ 23 - 0
test/unit/specs/misc_spec.js

@@ -445,4 +445,27 @@ describe('Misc', function () {
     })
     expect(vm.$el.firstChild.className).toBe('outer-hi')
   })
+
+  // #2163
+  it('slot compilation order with v-if', function () {
+    var vm = new Vue({
+      el: document.createElement('div'),
+      template:
+        '<test>' +
+          '<div slot="one">slot1</div>' +
+          'default content' +
+        '</test>',
+      components: {
+        test: {
+          template:
+            '<div>' +
+              '<slot v-if="true"></slot> ' +
+              '<slot name="one"></slot>' +
+            '</div>',
+          replace: true
+        }
+      }
+    })
+    expect(vm.$el.textContent).toBe('default content slot1')
+  })
 })