|
12 | 12 | :style="{ zIndex }" |
13 | 13 | class="vfm__overlay" |
14 | 14 | :class="[ |
15 | | - { 'vfm__overlay--attach': attach !== 'body' }, |
| 15 | + { 'vfm__overlay--attach': attach !== false }, |
16 | 16 | { 'vfm__overlay--prevent-click': preventClick }, |
17 | 17 | overlayClass |
18 | 18 | ]" |
|
31 | 31 | class="vfm__container" |
32 | 32 | :class="[ |
33 | 33 | { |
34 | | - 'vfm__container--attach': attach !== 'body', |
| 34 | + 'vfm__container--attach': attach !== false, |
35 | 35 | 'vfm__container--prevent-click': preventClick |
36 | 36 | }, |
37 | 37 | classes |
@@ -67,19 +67,27 @@ const TransitionState = { |
67 | 67 | Leaving: 'leavng' |
68 | 68 | } |
69 | 69 |
|
| 70 | +function validateAttachTarget(val) { |
| 71 | + const type = typeof val |
| 72 | +
|
| 73 | + if (type === 'boolean' || type === 'string') return true |
| 74 | +
|
| 75 | + return val.nodeType === Node.ELEMENT_NODE |
| 76 | +} |
| 77 | +
|
70 | 78 | export default { |
71 | 79 | name: 'VueFinalModal', |
72 | 80 | props: { |
73 | 81 | value: { type: Boolean, default: false }, |
74 | | - ssr: { type: Boolean, default: false }, |
| 82 | + ssr: { type: Boolean, default: true }, |
75 | 83 | classes: { type: [String, Object, Array], default: '' }, |
76 | 84 | contentClass: { type: [String, Object, Array], default: '' }, |
77 | 85 | lockScroll: { type: Boolean, default: true }, |
78 | 86 | hideOverlay: { type: Boolean, default: false }, |
79 | 87 | clickToClose: { type: Boolean, default: true }, |
80 | 88 | preventClick: { type: Boolean, default: false }, |
81 | 89 | overlayClass: { type: String, default: '' }, |
82 | | - attach: { type: null, default: 'body' }, |
| 90 | + attach: { type: null, default: false, validator: validateAttachTarget }, |
83 | 91 | transition: { type: String, default: 'vfm' }, |
84 | 92 | overlayTransition: { type: String, default: 'vfm' }, |
85 | 93 | zIndex: { type: [String, Number], default: 1000 } |
|
0 commit comments