File tree Expand file tree Collapse file tree 4 files changed +40
-6
lines changed
Expand file tree Collapse file tree 4 files changed +40
-6
lines changed Original file line number Diff line number Diff line change 11import { createWrapper , mount } from '@vue/test-utils'
2+ import { isVue3 } from '../../vue'
23import { waitNT , waitRAF } from '../../../tests/utils'
34import { getInstanceFromVNode } from '../../utils/get-instance-from-vnode'
45import { BModal } from './modal'
@@ -177,7 +178,9 @@ describe('modal', () => {
177178 expect ( outer ) . not . toBe ( null )
178179
179180 expect ( getInstanceFromVNode ( outer ) ) . toBeDefined ( ) // Target
180- expect ( getInstanceFromVNode ( outer ) . $options . name ) . toBe ( 'BVTransporterTarget' )
181+ if ( ! isVue3 ) {
182+ expect ( getInstanceFromVNode ( outer ) . $options . name ) . toBe ( 'BVTransporterTarget' )
183+ }
181184 expect ( outer . parentElement ) . toBeDefined ( )
182185 expect ( outer . parentElement ) . toBe ( document . body )
183186
Original file line number Diff line number Diff line change 11import { PortalTarget } from 'portal-vue'
22import { mount } from '@vue/test-utils'
3+ import { isVue3 } from '../../vue'
34import { waitNT , waitRAF } from '../../../tests/utils'
45import { BToaster } from './toaster'
56
@@ -27,7 +28,9 @@ describe('b-toaster', () => {
2728
2829 expect ( wrapper . find ( '.b-toaster-slot' ) . exists ( ) ) . toBe ( true )
2930 const $slot = wrapper . find ( '.b-toaster-slot' )
30- expect ( $slot . findComponent ( PortalTarget ) . exists ( ) ) . toBe ( true )
31+ if ( ! isVue3 ) {
32+ expect ( $slot . findComponent ( PortalTarget ) . exists ( ) ) . toBe ( true )
33+ }
3134 expect ( $slot . element . tagName ) . toBe ( 'DIV' )
3235 expect ( $slot . classes ( ) ) . toContain ( 'b-toaster-slot' )
3336 expect ( $slot . classes ( ) ) . toContain ( 'vue-portal-target' )
@@ -60,7 +63,9 @@ describe('b-toaster', () => {
6063
6164 expect ( wrapper . find ( '.b-toaster-slot' ) . exists ( ) ) . toBe ( true )
6265 const $slot = wrapper . find ( '.b-toaster-slot' )
63- expect ( $slot . findComponent ( PortalTarget ) . exists ( ) ) . toBe ( true )
66+ if ( ! isVue3 ) {
67+ expect ( $slot . findComponent ( PortalTarget ) . exists ( ) ) . toBe ( true )
68+ }
6469 expect ( $slot . element . tagName ) . toBe ( 'DIV' )
6570 expect ( $slot . classes ( ) ) . toContain ( 'b-toaster-slot' )
6671 expect ( $slot . classes ( ) ) . toContain ( 'vue-portal-target' )
Original file line number Diff line number Diff line change 1- import { Vue } from '../../vue'
1+ import { Vue , isVue3 } from '../../vue'
22import { NAME_TRANSPORTER , NAME_TRANSPORTER_TARGET } from '../../constants/components'
33import { IS_BROWSER } from '../../constants/env'
44import {
@@ -79,7 +79,7 @@ export const props = {
7979// --- Main component ---
8080
8181// @vue /component
82- export const BVTransporter = /*#__PURE__*/ Vue . extend ( {
82+ const BVTransporterVue2 = /*#__PURE__*/ Vue . extend ( {
8383 name : NAME_TRANSPORTER ,
8484 mixins : [ normalizeSlotMixin ] ,
8585 props,
@@ -177,3 +177,26 @@ export const BVTransporter = /*#__PURE__*/ Vue.extend({
177177 return h ( )
178178 }
179179} )
180+
181+ const BVTransporterVue3 = /*#__PURE__*/ Vue . extend ( {
182+ name : NAME_TRANSPORTER ,
183+ mixins : [ normalizeSlotMixin ] ,
184+ props,
185+ render ( h ) {
186+ if ( this . disabled ) {
187+ const $nodes = concat ( this . normalizeSlot ( ) ) . filter ( identity )
188+ if ( $nodes . length > 0 ) {
189+ return $nodes [ 0 ]
190+ }
191+ }
192+ return h (
193+ Vue . Teleport ,
194+ {
195+ to : this . container
196+ } ,
197+ this . normalizeSlot ( )
198+ )
199+ }
200+ } )
201+
202+ export const BVTransporter = isVue3 ? BVTransporterVue3 : BVTransporterVue2
Original file line number Diff line number Diff line change 1+ import { isVue3 } from '../../vue'
12import { mount } from '@vue/test-utils'
23import { waitNT } from '../../../tests/utils'
34import { getInstanceFromVNode } from '../../utils/get-instance-from-vnode'
@@ -45,7 +46,9 @@ describe('utils/transporter component', () => {
4546 expect ( target ) . toBeDefined ( )
4647 expect ( target ) . not . toBe ( null )
4748 expect ( getInstanceFromVNode ( target ) ) . toBeDefined ( ) // Target
48- expect ( getInstanceFromVNode ( target ) . $options . name ) . toBe ( 'BVTransporterTarget' )
49+ if ( ! isVue3 ) {
50+ expect ( getInstanceFromVNode ( target ) . $options . name ) . toBe ( 'BVTransporterTarget' )
51+ }
4952 expect ( target . tagName ) . toEqual ( 'DIV' )
5053 expect ( target . parentElement ) . toBeDefined ( )
5154 expect ( target . parentElement ) . toBe ( document . body )
You can’t perform that action at this time.
0 commit comments