From a2370cc53cfed4d7a646af857e3540ebf25e60eb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thorsten=20L=C3=BCnborg?=
Date: Tue, 12 Dec 2017 16:29:48 +0100
Subject: [PATCH] Fix update attributes ( close #90) (#91)
* improve example for testing updateAttribtutes
* Fix updateAttributes bug
(Fix #90)
* change `utils/extractAttributes` to generate a vnode-compatible data object
* remove `utils/updateAttributes` method and references in hooks and methods
* make `this.attributes` return an empty object by default
* fix `noWrapper` computed prop which relied in `!this.attributes`
* fix render function to spread `this.attributes` it onto the root element
* 1.2.1-beta.1
* bump version
---
dist/portal-vue.js | 48 ++++++++++++---------------
dist/portal-vue.js.map | 2 +-
dist/portal-vue.min.js | 2 +-
example/index.html | 2 +-
package.json | 2 +-
src/components/portal-target.js | 21 ++++--------
src/utils.js | 24 ++++++--------
test/unit/specs/portal-target.spec.js | 2 --
8 files changed, 43 insertions(+), 60 deletions(-)
diff --git a/dist/portal-vue.js b/dist/portal-vue.js
index 78bbe57..a5e049e 100644
--- a/dist/portal-vue.js
+++ b/dist/portal-vue.js
@@ -1,6 +1,6 @@
/*
portal-vue
- Version: 1.2.0
+ Version: 1.2.1-beta.1
Licence: MIT
(c) Thorsten Lünborg
*/
@@ -126,23 +126,22 @@ function extractAttributes(el) {
attrs[attr.name] = attr.value === '' ? true : attr.value;
}
}
- return attrs;
-}
-
-function updateAttributes(attrs, el) {
- // special treatment for class
+ var klass = void 0,
+ style = void 0;
if (attrs.class) {
- attrs.class.trim().split(' ').forEach(function (klass) {
- el.classList.add(klass);
- });
+ klass = attrs.class;
delete attrs.class;
}
-
- var keys = Object.keys(attrs);
-
- for (var i = 0; i < keys.length; i++) {
- el.setAttribute(keys[i], attrs[keys[i]]);
+ if (attrs.style) {
+ style = attrs.style;
+ delete attrs.style;
}
+ var data = {
+ attrs: attrs,
+ class: klass,
+ style: style
+ };
+ return data;
}
function freeze(item) {
@@ -345,7 +344,9 @@ var Target = {
abstract: true,
name: 'portalTarget',
props: {
- attributes: { type: Object },
+ attributes: { type: Object, default: function _default() {
+ return {};
+ } },
multiple: { type: Boolean, default: false },
name: { type: String, required: true },
slim: { type: Boolean, default: false },
@@ -370,8 +371,6 @@ var Target = {
var _this = this;
this.unwatch = this.$watch('ownTransports', this.emitChange);
-
- this.updateAttributes();
this.$nextTick(function () {
if (_this.transition) {
// only when we have a transition, because it causes a re-render
@@ -379,9 +378,6 @@ var Target = {
}
});
},
- updated: function updated() {
- this.updateAttributes();
- },
beforeDestroy: function beforeDestroy() {
this.unwatch();
this.$el.innerHTML = '';
@@ -389,11 +385,6 @@ var Target = {
methods: {
- updateAttributes: function updateAttributes$$1() {
- if (this.attributes) {
- updateAttributes(this.attributes, this.$el);
- }
- },
emitChange: function emitChange(newTransports, oldTransports) {
if (this.multiple) {
this.$emit('change', [].concat(toConsumableArray(newTransports)), [].concat(toConsumableArray(oldTransports)));
@@ -418,8 +409,11 @@ var Target = {
children: function children() {
return this.passengers.length !== 0 ? this.passengers : this.$slots.default || [];
},
+ hasAttributes: function hasAttributes() {
+ return Object.keys(this.attributes).length > 0;
+ },
noWrapper: function noWrapper() {
- var noWrapper = !this.attributes && this.slim;
+ var noWrapper = !this.hasAttributes && this.slim;
if (noWrapper && this.children.length > 1) {
console.warn('[portal-vue]: PortalTarget with `slim` option received more than one child element.');
}
@@ -471,7 +465,7 @@ var Target = {
return this.noWrapper ? this.children[0] : h(
Tag,
- { 'class': 'vue-portal-target', key: wrapperKey },
+ babelHelperVueJsxMergeProps([{ 'class': 'vue-portal-target' }, this.attributes, { key: wrapperKey }]),
[this.children]
);
}
diff --git a/dist/portal-vue.js.map b/dist/portal-vue.js.map
index 1df5b45..8de23e5 100644
--- a/dist/portal-vue.js.map
+++ b/dist/portal-vue.js.map
@@ -1 +1 @@
-{"version":3,"file":"portal-vue.js","sources":["../src/utils.js","../src/components/wormhole.js","../node_modules/babel-helper-vue-jsx-merge-props/index.js","../src/components/portal-target.js","../src/components/portal.js","../src/index.js"],"sourcesContent":["export function extractAttributes (el) {\n const map = el.hasAttributes() ? el.attributes : []\n const attrs = {}\n for (let i = 0; i < map.length; i++) {\n const attr = map[i]\n if (attr.value) {\n attrs[attr.name] = attr.value === '' ? true : attr.value\n }\n }\n return attrs\n}\n\nexport function updateAttributes (attrs, el) {\n // special treatment for class\n if (attrs.class) {\n attrs.class.trim().split(' ').forEach((klass) => {\n el.classList.add(klass)\n })\n delete attrs.class\n }\n\n const keys = Object.keys(attrs)\n\n for (let i = 0; i < keys.length; i++) {\n el.setAttribute(keys[i], attrs[keys[i]])\n }\n}\n\nexport function freeze (item) {\n if (Array.isArray(item) || typeof item === 'object') {\n return Object.freeze(item)\n }\n return item\n}\n\nexport function combinePassengers (transports) {\n let passengers = []\n for (const transport of transports) {\n passengers = passengers.concat(transport.passengers)\n }\n return passengers\n}\n","import Vue from 'vue'\nimport { combinePassengers, freeze } from '../utils'\nconst transports = {}\n\nexport { transports }\n\nexport class Wormhole {\n constructor (transports) {\n this.transports = transports\n }\n\n open (transport) {\n const { to, from, passengers } = transport\n if (!to || !from || !passengers) return\n\n transport.passengers = freeze(passengers)\n const keys = Object.keys(this.transports)\n if (keys.indexOf(to) === -1) {\n Vue.set(this.transports, to, [])\n }\n\n const currentIndex = this.getTransportIndex(transport)\n // Copying the array here so that the PortalTarget change event will actually contain two distinct arrays\n const newTransports = this.transports[to].slice(0)\n if (currentIndex === -1) {\n newTransports.push(transport)\n } else {\n newTransports[currentIndex] = transport\n }\n newTransports.sort(function (a, b) {\n return a.order - b.order\n })\n\n this.transports[to] = newTransports\n }\n\n close (transport, force = false) {\n const { to, from } = transport\n if (!to || !from) return\n if (!this.transports[to]) {\n return\n }\n\n if (force) {\n this.transports[to] = []\n } else {\n const index = this.getTransportIndex(transport)\n if (index >= 0) {\n // Copying the array here so that the PortalTarget change event will actually contain two distinct arrays\n const newTransports = this.transports[to].slice(0)\n newTransports.splice(index, 1)\n this.transports[to] = newTransports\n }\n }\n }\n\n hasTarget (to) {\n return this.transports.hasOwnProperty(to)\n }\n\n hasContentFor (to) {\n if (!this.transports[to]) {\n return false\n }\n return this.getContentFor(to).length > 0\n }\n\n getSourceFor (to) {\n return this.transports[to] && this.transports[to][0].from\n }\n\n getContentFor (to) {\n const transports = this.transports[to]\n if (!transports) {\n return undefined\n }\n return combinePassengers(transports)\n }\n\n getTransportIndex ({ to, from }) {\n for (const i in this.transports[to]) {\n if (this.transports[to][i].from === from) {\n return i\n }\n }\n return -1\n }\n}\nconst wormhole = new Wormhole(transports)\nexport default wormhole\n","var nestRE = /^(attrs|props|on|nativeOn|class|style|hook)$/\n\nmodule.exports = function mergeJSXProps (objs) {\n return objs.reduce(function (a, b) {\n var aa, bb, key, nestedKey, temp\n for (key in b) {\n aa = a[key]\n bb = b[key]\n if (aa && nestRE.test(key)) {\n // normalize class\n if (key === 'class') {\n if (typeof aa === 'string') {\n temp = aa\n a[key] = aa = {}\n aa[temp] = true\n }\n if (typeof bb === 'string') {\n temp = bb\n b[key] = bb = {}\n bb[temp] = true\n }\n }\n if (key === 'on' || key === 'nativeOn' || key === 'hook') {\n // merge functions\n for (nestedKey in bb) {\n aa[nestedKey] = mergeFn(aa[nestedKey], bb[nestedKey])\n }\n } else if (Array.isArray(aa)) {\n a[key] = aa.concat(bb)\n } else if (Array.isArray(bb)) {\n a[key] = [aa].concat(bb)\n } else {\n for (nestedKey in bb) {\n aa[nestedKey] = bb[nestedKey]\n }\n }\n } else {\n a[key] = b[key]\n }\n }\n return a\n }, {})\n}\n\nfunction mergeFn (a, b) {\n return function () {\n a.apply(this, arguments)\n b.apply(this, arguments)\n }\n}\n","// import { transports } from './wormhole'\nimport { combinePassengers, updateAttributes } from '../utils'\nimport wormhole from './wormhole'\n\nexport default {\n abstract: true,\n name: 'portalTarget',\n props: {\n attributes: { type: Object },\n multiple: { type: Boolean, default: false },\n name: { type: String, required: true },\n slim: { type: Boolean, default: false },\n tag: { type: String, default: 'div' },\n transition: { type: [Boolean, String, Object], default: false },\n transitionEvents: { type: Object, default: () => ({}) },\n },\n data () {\n return {\n transports: wormhole.transports,\n firstRender: true,\n }\n },\n created () {\n if (!this.transports[this.name]) {\n this.$set(this.transports, this.name, [])\n }\n },\n mounted () {\n this.unwatch = this.$watch('ownTransports', this.emitChange)\n\n this.updateAttributes()\n this.$nextTick(() => {\n if (this.transition) { // only when we have a transition, because it causes a re-render\n this.firstRender = false\n }\n })\n },\n updated () {\n this.updateAttributes()\n },\n beforeDestroy () {\n this.unwatch()\n this.$el.innerHTML = ''\n },\n\n methods: {\n updateAttributes () {\n if (this.attributes) {\n updateAttributes(this.attributes, this.$el)\n }\n },\n emitChange (newTransports, oldTransports) {\n if (this.multiple) {\n this.$emit('change',\n [...newTransports],\n [...oldTransports]\n )\n } else {\n const newTransport = newTransports.length === 0 ? undefined : newTransports[0]\n const oldTransport = oldTransports.length === 0 ? undefined : oldTransports[0]\n this.$emit('change',\n { ...newTransport },\n { ...oldTransport }\n )\n }\n },\n },\n computed: {\n ownTransports () {\n const transports = this.transports[this.name] || []\n if (this.multiple) {\n return transports\n }\n return transports.length === 0 ? [] : [transports[transports.length - 1]]\n },\n passengers () {\n return combinePassengers(this.ownTransports)\n },\n children () {\n return this.passengers.length !== 0 ? this.passengers : (this.$slots.default || [])\n },\n noWrapper () {\n const noWrapper = !this.attributes && this.slim\n if (noWrapper && this.children.length > 1) {\n console.warn('[portal-vue]: PortalTarget with `slim` option received more than one child element.')\n }\n return noWrapper\n },\n withTransition () {\n return !!this.transition\n },\n transitionData () {\n const t = this.transition\n const data = {}\n\n // During first render, we render a dumb transition without any classes, events and a fake name\n // We have to do this to emulate the normal behaviour of transitions without `appear`\n // because in Portals, transitions can behave as if appear was defined under certain conditions.\n if (this.firstRender && (typeof this.transition === 'object' && !this.transition.appear)) {\n data.props = { name: '__notranstition__portal-vue__' }\n return data\n }\n\n if (typeof t === 'string') {\n data.props = { name: t }\n } else if (typeof t === 'object') {\n data.props = t\n }\n if (this.renderSlim) {\n data.props.tag = this.tag\n }\n data.on = this.transitionEvents\n\n return data\n },\n },\n\n render (h) {\n const TransitionType = this.noWrapper ? 'transition' : 'transition-group'\n const Tag = this.tag\n\n if (this.withTransition) {\n return (\n \n {this.children}\n \n )\n }\n\n // Solves a bug where Vue would sometimes duplicate elements upon changing multiple or disabled\n const wrapperKey = this.ownTransports.length\n\n return this.noWrapper\n ? this.children[0]\n : {this.children}\n },\n}\n","\nimport Vue from 'vue'\nimport wormhole from './wormhole'\nimport Target from './portal-target'\nimport { extractAttributes } from '../utils'\n\nconst inBrowser = (typeof window !== 'undefined')\n\nlet pid = 1\n\nexport default {\n abstract: true,\n name: 'portal',\n props: {\n /* global HTMLElement */\n disabled: { type: Boolean, default: false },\n name: { type: String, default: () => String(pid++) },\n order: { type: Number, default: 0 },\n slim: { type: Boolean, default: false },\n tag: { type: [String], default: 'DIV' },\n targetEl: { type: inBrowser ? [String, HTMLElement] : String },\n to: { type: String, default: () => String(Math.round(Math.random() * 10000000)) },\n },\n\n mounted () {\n if (this.targetEl) {\n this.mountToTarget()\n }\n if (!this.disabled) {\n this.sendUpdate()\n }\n },\n\n updated () {\n if (this.disabled) {\n this.clear()\n } else {\n this.sendUpdate()\n }\n },\n\n beforeDestroy () {\n this.clear()\n if (this.mountedComp) {\n this.mountedComp.$destroy()\n }\n },\n\n watch: {\n to (newValue, oldValue) {\n oldValue && this.clear(oldValue)\n this.sendUpdate()\n },\n targetEl (newValue, oldValue) {\n if (newValue) {\n this.mountToTarget()\n }\n },\n },\n\n methods: {\n\n sendUpdate () {\n if (this.$slots.default) {\n wormhole.open({\n from: this.name,\n to: this.to,\n passengers: [...this.$slots.default],\n order: this.order,\n })\n } else {\n this.clear()\n }\n },\n\n clear (target) {\n wormhole.close({\n from: this.name,\n to: target || this.to,\n })\n },\n\n mountToTarget () {\n let el\n const target = this.targetEl\n\n if (typeof target === 'string') {\n el = document.querySelector(target)\n } else if (target instanceof HTMLElement) {\n el = target\n } else {\n console.warn('[vue-portal]: value of targetEl must be of type String or HTMLElement')\n return\n }\n\n if (el) {\n const newTarget = new Vue({\n ...Target,\n parent: this,\n propsData: {\n name: this.to,\n tag: el.tagName,\n attributes: extractAttributes(el),\n },\n })\n newTarget.$mount(el)\n this.mountedComp = newTarget\n } else {\n console.warn('[vue-portal]: The specified targetEl ' + target + ' was not found')\n }\n },\n },\n\n render (h) {\n const children = this.$slots.default || []\n const Tag = this.tag\n if (children.length && this.disabled) {\n return children.length <= 1 && this.slim\n ? children[0]\n : ({children})\n } else {\n return ()\n // h(this.tag, { class: { 'v-portal': true }, style: { display: 'none' }, key: 'v-portal-placeholder' })\n }\n },\n}\n","import Portal from './components/portal.js'\nimport PortalTarget from './components/portal-target.js'\nimport Wormhole from './components/wormhole.js'\n\nfunction install (Vue, opts = {}) {\n Vue.component(opts.portalName || 'portal', Portal)\n Vue.component(opts.portalTargetName || 'portal-target', PortalTarget)\n}\nif (typeof window !== 'undefined' && window.Vue) {\n window.Vue.use({ install: install })\n}\n\nexport default {\n install,\n Portal,\n PortalTarget,\n Wormhole,\n}\n"],"names":["extractAttributes","el","map","hasAttributes","attributes","attrs","i","length","attr","value","name","updateAttributes","class","trim","split","forEach","klass","classList","add","keys","Object","setAttribute","freeze","item","Array","isArray","combinePassengers","transports","passengers","transport","concat","Wormhole","to","from","indexOf","set","currentIndex","getTransportIndex","newTransports","slice","push","sort","a","b","order","force","index","splice","hasOwnProperty","getContentFor","undefined","wormhole","type","Boolean","default","String","required","$set","unwatch","$watch","emitChange","$nextTick","transition","firstRender","$el","innerHTML","oldTransports","multiple","$emit","newTransport","oldTransport","ownTransports","$slots","noWrapper","slim","children","warn","t","data","babelHelpers.typeof","appear","props","renderSlim","tag","on","transitionEvents","h","TransitionType","Tag","withTransition","transitionData","wrapperKey","inBrowser","window","pid","Number","HTMLElement","Math","round","random","targetEl","mountToTarget","disabled","sendUpdate","clear","mountedComp","$destroy","newValue","oldValue","open","target","close","document","querySelector","newTarget","Vue","Target","tagName","$mount","install","opts","component","portalName","Portal","portalTargetName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IAAyB,eAAvC,EAAwDC,MAAxD;;AAEF,IAAI,OAAOhC,MAAP,KAAkB,WAAlB,IAAiCA,OAAOsB,GAA5C,EAAiD;SACxCA,GAAP,CAAWW,GAAX,CAAe,EAAEP,SAASA,OAAX,EAAf;;;AAGF,YAAe;kBAAA;gBAAA;sBAAA;;CAAf;;;;;;;;"}
\ No newline at end of file
+{"version":3,"file":"portal-vue.js","sources":["../src/utils.js","../src/components/wormhole.js","../node_modules/babel-helper-vue-jsx-merge-props/index.js","../src/components/portal-target.js","../src/components/portal.js","../src/index.js"],"sourcesContent":["export function extractAttributes (el) {\n const map = el.hasAttributes() ? el.attributes : []\n const attrs = {}\n for (let i = 0; i < map.length; i++) {\n const attr = map[i]\n if (attr.value) {\n attrs[attr.name] = attr.value === '' ? true : attr.value\n }\n }\n let klass, style\n if (attrs.class) {\n klass = attrs.class\n delete attrs.class\n }\n if (attrs.style) {\n style = attrs.style\n delete attrs.style\n }\n const data = {\n attrs,\n class: klass,\n style,\n }\n return data\n}\n\nexport function freeze (item) {\n if (Array.isArray(item) || typeof item === 'object') {\n return Object.freeze(item)\n }\n return item\n}\n\nexport function combinePassengers (transports) {\n let passengers = []\n for (const transport of transports) {\n passengers = passengers.concat(transport.passengers)\n }\n return passengers\n}\n","import Vue from 'vue'\nimport { combinePassengers, freeze } from '../utils'\nconst transports = {}\n\nexport { transports }\n\nexport class Wormhole {\n constructor (transports) {\n this.transports = transports\n }\n\n open (transport) {\n const { to, from, passengers } = transport\n if (!to || !from || !passengers) return\n\n transport.passengers = freeze(passengers)\n const keys = Object.keys(this.transports)\n if (keys.indexOf(to) === -1) {\n Vue.set(this.transports, to, [])\n }\n\n const currentIndex = this.getTransportIndex(transport)\n // Copying the array here so that the PortalTarget change event will actually contain two distinct arrays\n const newTransports = this.transports[to].slice(0)\n if (currentIndex === -1) {\n newTransports.push(transport)\n } else {\n newTransports[currentIndex] = transport\n }\n newTransports.sort(function (a, b) {\n return a.order - b.order\n })\n\n this.transports[to] = newTransports\n }\n\n close (transport, force = false) {\n const { to, from } = transport\n if (!to || !from) return\n if (!this.transports[to]) {\n return\n }\n\n if (force) {\n this.transports[to] = []\n } else {\n const index = this.getTransportIndex(transport)\n if (index >= 0) {\n // Copying the array here so that the PortalTarget change event will actually contain two distinct arrays\n const newTransports = this.transports[to].slice(0)\n newTransports.splice(index, 1)\n this.transports[to] = newTransports\n }\n }\n }\n\n hasTarget (to) {\n return this.transports.hasOwnProperty(to)\n }\n\n hasContentFor (to) {\n if (!this.transports[to]) {\n return false\n }\n return this.getContentFor(to).length > 0\n }\n\n getSourceFor (to) {\n return this.transports[to] && this.transports[to][0].from\n }\n\n getContentFor (to) {\n const transports = this.transports[to]\n if (!transports) {\n return undefined\n }\n return combinePassengers(transports)\n }\n\n getTransportIndex ({ to, from }) {\n for (const i in this.transports[to]) {\n if (this.transports[to][i].from === from) {\n return i\n }\n }\n return -1\n }\n}\nconst wormhole = new Wormhole(transports)\nexport default wormhole\n","var nestRE = /^(attrs|props|on|nativeOn|class|style|hook)$/\n\nmodule.exports = function mergeJSXProps (objs) {\n return objs.reduce(function (a, b) {\n var aa, bb, key, nestedKey, temp\n for (key in b) {\n aa = a[key]\n bb = b[key]\n if (aa && nestRE.test(key)) {\n // normalize class\n if (key === 'class') {\n if (typeof aa === 'string') {\n temp = aa\n a[key] = aa = {}\n aa[temp] = true\n }\n if (typeof bb === 'string') {\n temp = bb\n b[key] = bb = {}\n bb[temp] = true\n }\n }\n if (key === 'on' || key === 'nativeOn' || key === 'hook') {\n // merge functions\n for (nestedKey in bb) {\n aa[nestedKey] = mergeFn(aa[nestedKey], bb[nestedKey])\n }\n } else if (Array.isArray(aa)) {\n a[key] = aa.concat(bb)\n } else if (Array.isArray(bb)) {\n a[key] = [aa].concat(bb)\n } else {\n for (nestedKey in bb) {\n aa[nestedKey] = bb[nestedKey]\n }\n }\n } else {\n a[key] = b[key]\n }\n }\n return a\n }, {})\n}\n\nfunction mergeFn (a, b) {\n return function () {\n a.apply(this, arguments)\n b.apply(this, arguments)\n }\n}\n","// import { transports } from './wormhole'\nimport { combinePassengers } from '../utils'\nimport wormhole from './wormhole'\n\nexport default {\n abstract: true,\n name: 'portalTarget',\n props: {\n attributes: { type: Object, default: () => ({}) },\n multiple: { type: Boolean, default: false },\n name: { type: String, required: true },\n slim: { type: Boolean, default: false },\n tag: { type: String, default: 'div' },\n transition: { type: [Boolean, String, Object], default: false },\n transitionEvents: { type: Object, default: () => ({}) },\n },\n data () {\n return {\n transports: wormhole.transports,\n firstRender: true,\n }\n },\n created () {\n if (!this.transports[this.name]) {\n this.$set(this.transports, this.name, [])\n }\n },\n mounted () {\n this.unwatch = this.$watch('ownTransports', this.emitChange)\n this.$nextTick(() => {\n if (this.transition) { // only when we have a transition, because it causes a re-render\n this.firstRender = false\n }\n })\n },\n beforeDestroy () {\n this.unwatch()\n this.$el.innerHTML = ''\n },\n\n methods: {\n emitChange (newTransports, oldTransports) {\n if (this.multiple) {\n this.$emit('change',\n [...newTransports],\n [...oldTransports]\n )\n } else {\n const newTransport = newTransports.length === 0 ? undefined : newTransports[0]\n const oldTransport = oldTransports.length === 0 ? undefined : oldTransports[0]\n this.$emit('change',\n { ...newTransport },\n { ...oldTransport }\n )\n }\n },\n },\n computed: {\n ownTransports () {\n const transports = this.transports[this.name] || []\n if (this.multiple) {\n return transports\n }\n return transports.length === 0 ? [] : [transports[transports.length - 1]]\n },\n passengers () {\n return combinePassengers(this.ownTransports)\n },\n children () {\n return this.passengers.length !== 0 ? this.passengers : (this.$slots.default || [])\n },\n hasAttributes () {\n return Object.keys(this.attributes).length > 0\n },\n noWrapper () {\n const noWrapper = !this.hasAttributes && this.slim\n if (noWrapper && this.children.length > 1) {\n console.warn('[portal-vue]: PortalTarget with `slim` option received more than one child element.')\n }\n return noWrapper\n },\n withTransition () {\n return !!this.transition\n },\n transitionData () {\n const t = this.transition\n const data = {}\n\n // During first render, we render a dumb transition without any classes, events and a fake name\n // We have to do this to emulate the normal behaviour of transitions without `appear`\n // because in Portals, transitions can behave as if appear was defined under certain conditions.\n if (this.firstRender && (typeof this.transition === 'object' && !this.transition.appear)) {\n data.props = { name: '__notranstition__portal-vue__' }\n return data\n }\n\n if (typeof t === 'string') {\n data.props = { name: t }\n } else if (typeof t === 'object') {\n data.props = t\n }\n if (this.renderSlim) {\n data.props.tag = this.tag\n }\n data.on = this.transitionEvents\n\n return data\n },\n },\n\n render (h) {\n const TransitionType = this.noWrapper ? 'transition' : 'transition-group'\n const Tag = this.tag\n\n if (this.withTransition) {\n return (\n \n {this.children}\n \n )\n }\n\n // Solves a bug where Vue would sometimes duplicate elements upon changing multiple or disabled\n const wrapperKey = this.ownTransports.length\n\n return this.noWrapper\n ? this.children[0]\n : {this.children}\n },\n}\n","\nimport Vue from 'vue'\nimport wormhole from './wormhole'\nimport Target from './portal-target'\nimport { extractAttributes } from '../utils'\n\nconst inBrowser = (typeof window !== 'undefined')\n\nlet pid = 1\n\nexport default {\n abstract: true,\n name: 'portal',\n props: {\n /* global HTMLElement */\n disabled: { type: Boolean, default: false },\n name: { type: String, default: () => String(pid++) },\n order: { type: Number, default: 0 },\n slim: { type: Boolean, default: false },\n tag: { type: [String], default: 'DIV' },\n targetEl: { type: inBrowser ? [String, HTMLElement] : String },\n to: { type: String, default: () => String(Math.round(Math.random() * 10000000)) },\n },\n\n mounted () {\n if (this.targetEl) {\n this.mountToTarget()\n }\n if (!this.disabled) {\n this.sendUpdate()\n }\n },\n\n updated () {\n if (this.disabled) {\n this.clear()\n } else {\n this.sendUpdate()\n }\n },\n\n beforeDestroy () {\n this.clear()\n if (this.mountedComp) {\n this.mountedComp.$destroy()\n }\n },\n\n watch: {\n to (newValue, oldValue) {\n oldValue && this.clear(oldValue)\n this.sendUpdate()\n },\n targetEl (newValue, oldValue) {\n if (newValue) {\n this.mountToTarget()\n }\n },\n },\n\n methods: {\n\n sendUpdate () {\n if (this.$slots.default) {\n wormhole.open({\n from: this.name,\n to: this.to,\n passengers: [...this.$slots.default],\n order: this.order,\n })\n } else {\n this.clear()\n }\n },\n\n clear (target) {\n wormhole.close({\n from: this.name,\n to: target || this.to,\n })\n },\n\n mountToTarget () {\n let el\n const target = this.targetEl\n\n if (typeof target === 'string') {\n el = document.querySelector(target)\n } else if (target instanceof HTMLElement) {\n el = target\n } else {\n console.warn('[vue-portal]: value of targetEl must be of type String or HTMLElement')\n return\n }\n\n if (el) {\n const newTarget = new Vue({\n ...Target,\n parent: this,\n propsData: {\n name: this.to,\n tag: el.tagName,\n attributes: extractAttributes(el),\n },\n })\n newTarget.$mount(el)\n this.mountedComp = newTarget\n } else {\n console.warn('[vue-portal]: The specified targetEl ' + target + ' was not found')\n }\n },\n },\n\n render (h) {\n const children = this.$slots.default || []\n const Tag = this.tag\n if (children.length && this.disabled) {\n return children.length <= 1 && this.slim\n ? children[0]\n : ({children})\n } else {\n return ()\n // h(this.tag, { class: { 'v-portal': true }, style: { display: 'none' }, key: 'v-portal-placeholder' })\n }\n },\n}\n","import Portal from './components/portal.js'\nimport PortalTarget from './components/portal-target.js'\nimport Wormhole from './components/wormhole.js'\n\nfunction install (Vue, opts = {}) {\n Vue.component(opts.portalName || 'portal', Portal)\n Vue.component(opts.portalTargetName || 'portal-target', PortalTarget)\n}\nif (typeof window !== 'undefined' && window.Vue) {\n window.Vue.use({ install: install })\n}\n\nexport default {\n install,\n Portal,\n PortalTarget,\n Wormhole,\n}\n"],"names":["extractAttributes","el","map","hasAttributes","attributes","attrs","i","length","attr","value","name","klass","style","class","data","freeze","item","Array","isArray","Object","combinePassengers","transports","passengers","transport","concat","Wormhole","to","from","keys","indexOf","set","currentIndex","getTransportIndex","newTransports","slice","push","sort","a","b","order","force","index","splice","hasOwnProperty","getContentFor","undefined","wormhole","type","default","Boolean","String","required","$set","unwatch","$watch","emitChange","$nextTick","transition","firstRender","$el","innerHTML","oldTransports","multiple","$emit","newTransport","oldTransport","ownTransports","$slots","noWrapper","slim","children","warn","t","babelHelpers.typeof","appear","props","renderSlim","tag","on","transitionEvents","h","TransitionType","Tag","withTransition","transitionData","wrapperKey","inBrowser","window","pid","Number","HTMLElement","Math","round","random","targetEl","mountToTarget","disabled","sendUpdate","clear","mountedComp","$destroy","newValue","oldValue","open","target","close","document","querySelector","newTarget","Vue","Target","tagName","$mount","install","opts","component","portalName","Portal","portalTargetName","PortalTarget","use"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAO,SAASA,iBAAT,CAA4BC,EAA5B,EAAgC;MAC/BC,MAAMD,GAAGE,aAAH,KAAqBF,GAAGG,UAAxB,GAAqC,EAAjD;MACMC,QAAQ,EAAd;OACK,IAAIC,IAAI,CAAb,EAAgBA,IAAIJ,IAAIK,MAAxB,EAAgCD,GAAhC,EAAqC;QAC7BE,OAAON,IAAII,CAAJ,CAAb;QACIE,KAAKC,KAAT,EAAgB;YACRD,KAAKE,IAAX,IAAmBF,KAAKC,KAAL,KAAe,EAAf,GAAoB,IAApB,GAA2BD,KAAKC,KAAnD;;;MAGAE,cAAJ;MAAWC,cAAX;MACIP,MAAMQ,KAAV,EAAiB;YACPR,MAAMQ,KAAd;WACOR,MAAMQ,KAAb;;MAEER,MAAMO,KAAV,EAAiB;YACPP,MAAMO,KAAd;WACOP,MAAMO,KAAb;;MAEIE,OAAO;gBAAA;WAEJH,KAFI;;GAAb;SAKOG,IAAP;;;AAGF,AAAO,SAASC,MAAT,CAAiBC,IAAjB,EAAuB;MACxBC,MAAMC,OAAN,CAAcF,IAAd,KAAuB,QAAOA,IAAP,yCAAOA,IAAP,OAAgB,QAA3C,EAAqD;WAC5CG,OAAOJ,MAAP,CAAcC,IAAd,CAAP;;SAEKA,IAAP;;;AAGF,AAAO,SAASI,iBAAT,CAA4BC,UAA5B,EAAwC;MACzCC,aAAa,EAAjB;;;;;;yBACwBD,UAAxB,8HAAoC;UA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ACxCA,GAAP,CAAWW,GAAX,CAAe,EAAEP,SAASA,OAAX,EAAf;;;AAGF,YAAe;kBAAA;gBAAA;sBAAA;;CAAf;;;;;;;;"}
\ No newline at end of file
diff --git a/dist/portal-vue.min.js b/dist/portal-vue.min.js
index 1ac19d5..60c049b 100644
--- a/dist/portal-vue.min.js
+++ b/dist/portal-vue.min.js
@@ -1 +1 @@
-!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("vue")):"function"==typeof define&&define.amd?define(["vue"],e):t.PortalVue=e(t.Vue)}(this,function(t){"use strict";function e(t){for(var e=t.hasAttributes()?t.attributes:[],n={},r=0;r1&&void 0!==arguments[1]?arguments[1]:{};t.component(e.portalName||"portal",w),t.component(e.portalTargetName||"portal-target",m)}t=t&&"default"in t?t.default:t;var a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},l=function(){function t(t,e){for(var n=0;n1&&void 0!==arguments[1]&&arguments[1],n=t.to,r=t.from;if(n&&r&&this.transports[n])if(e)this.transports[n]=[];else{var o=this.getTransportIndex(t);if(o>=0){var i=this.transports[n].slice(0);i.splice(o,1),this.transports[n]=i}}}},{key:"hasTarget",value:function(t){return this.transports.hasOwnProperty(t)}},{key:"hasContentFor",value:function(t){return!!this.transports[t]&&this.getContentFor(t).length>0}},{key:"getSourceFor",value:function(t){return this.transports[t]&&this.transports[t][0].from}},{key:"getContentFor",value:function(t){var e=this.transports[t];if(e)return o(e)}},{key:"getTransportIndex",value:function(t){var e=t.to,n=t.from;for(var r in this.transports[e])if(this.transports[e][r].from===n)return r;return-1}}]),e}(),d=new c(p),y=/^(attrs|props|on|nativeOn|class|style|hook)$/,g=function(t){return t.reduce(function(t,e){var n,r,o,s,a;for(o in e)if(n=t[o],r=e[o],n&&y.test(o))if("class"===o&&("string"==typeof n&&(a=n,t[o]=n={},n[a]=!0),"string"==typeof r&&(a=r,e[o]=r={},r[a]=!0)),"on"===o||"nativeOn"===o||"hook"===o)for(s in r)n[s]=i(n[s],r[s]);else if(Array.isArray(n))t[o]=n.concat(r);else if(Array.isArray(r))t[o]=[n].concat(r);else for(s in r)n[s]=r[s];else t[o]=e[o];return t},{})},m={abstract:!0,name:"portalTarget",props:{attributes:{type:Object},multiple:{type:Boolean,default:!1},name:{type:String,required:!0},slim:{type:Boolean,default:!1},tag:{type:String,default:"div"},transition:{type:[Boolean,String,Object],default:!1},transitionEvents:{type:Object,default:function(){return{}}}},data:function(){return{transports:d.transports,firstRender:!0}},created:function(){this.transports[this.name]||this.$set(this.transports,this.name,[])},mounted:function(){var t=this;this.unwatch=this.$watch("ownTransports",this.emitChange),this.updateAttributes(),this.$nextTick(function(){t.transition&&(t.firstRender=!1)})},updated:function(){this.updateAttributes()},beforeDestroy:function(){this.unwatch(),this.$el.innerHTML=""},methods:{updateAttributes:function(){this.attributes&&n(this.attributes,this.$el)},emitChange:function(t,e){if(this.multiple)this.$emit("change",[].concat(h(t)),[].concat(h(e)));else{var n=0===t.length?void 0:t[0],r=0===e.length?void 0:e[0];this.$emit("change",f({},n),f({},r))}}},computed:{ownTransports:function(){var t=this.transports[this.name]||[];return this.multiple?t:0===t.length?[]:[t[t.length-1]]},passengers:function(){return o(this.ownTransports)},children:function(){return 0!==this.passengers.length?this.passengers:this.$slots.default||[]},noWrapper:function(){var t=!this.attributes&&this.slim;return t&&this.children.length>1&&console.warn("[portal-vue]: PortalTarget with `slim` option received more than one child element."),t},withTransition:function(){return!!this.transition},transitionData:function(){var t=this.transition,e={};return this.firstRender&&"object"===a(this.transition)&&!this.transition.appear?(e.props={name:"__notranstition__portal-vue__"},e):("string"==typeof t?e.props={name:t}:"object"===(void 0===t?"undefined":a(t))&&(e.props=t),this.renderSlim&&(e.props.tag=this.tag),e.on=this.transitionEvents,e)}},render:function(t){var e=this.noWrapper?"transition":"transition-group",n=this.tag;if(this.withTransition)return t(e,g([this.transitionData,{class:"vue-portal-target"}]),[this.children]);var r=this.ownTransports.length;return this.noWrapper?this.children[0]:t(n,{class:"vue-portal-target",key:r},[this.children])}},v="undefined"!=typeof window,b=1,w={abstract:!0,name:"portal",props:{disabled:{type:Boolean,default:!1},name:{type:String,default:function(){return String(b++)}},order:{type:Number,default:0},slim:{type:Boolean,default:!1},tag:{type:[String],default:"DIV"},targetEl:{type:v?[String,HTMLElement]:String},to:{type:String,default:function(){return String(Math.round(1e7*Math.random()))}}},mounted:function(){this.targetEl&&this.mountToTarget(),this.disabled||this.sendUpdate()},updated:function(){this.disabled?this.clear():this.sendUpdate()},beforeDestroy:function(){this.clear(),this.mountedComp&&this.mountedComp.$destroy()},watch:{to:function(t,e){e&&this.clear(e),this.sendUpdate()},targetEl:function(t,e){t&&this.mountToTarget()}},methods:{sendUpdate:function(){this.$slots.default?d.open({from:this.name,to:this.to,passengers:[].concat(h(this.$slots.default)),order:this.order}):this.clear()},clear:function(t){d.close({from:this.name,to:t||this.to})},mountToTarget:function(){var n=void 0,r=this.targetEl;if("string"==typeof r)n=document.querySelector(r);else{if(!(r instanceof HTMLElement))return void console.warn("[vue-portal]: value of targetEl must be of type String or HTMLElement");n=r}if(n){var o=new t(f({},m,{parent:this,propsData:{name:this.to,tag:n.tagName,attributes:e(n)}}));o.$mount(n),this.mountedComp=o}else console.warn("[vue-portal]: The specified targetEl "+r+" was not found")}},render:function(t){var e=this.$slots.default||[],n=this.tag;return e.length&&this.disabled?e.length<=1&&this.slim?e[0]:t(n,null,[e]):t(n,{class:"v-portal",style:"display: none",key:"v-portal-placeholder"},[])}};return"undefined"!=typeof window&&window.Vue&&window.Vue.use({install:s}),{install:s,Portal:w,PortalTarget:m,Wormhole:d}});
+!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("vue")):"function"==typeof define&&define.amd?define(["vue"],e):t.PortalVue=e(t.Vue)}(this,function(t){"use strict";function e(t){for(var e=t.hasAttributes()?t.attributes:[],n={},r=0;r1&&void 0!==arguments[1]?arguments[1]:{};t.component(e.portalName||"portal",b),t.component(e.portalTargetName||"portal-target",g)}t=t&&"default"in t?t.default:t;var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},a=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},u=function(){function t(t,e){for(var n=0;n1&&void 0!==arguments[1]&&arguments[1],n=t.to,r=t.from;if(n&&r&&this.transports[n])if(e)this.transports[n]=[];else{var o=this.getTransportIndex(t);if(o>=0){var s=this.transports[n].slice(0);s.splice(o,1),this.transports[n]=s}}}},{key:"hasTarget",value:function(t){return this.transports.hasOwnProperty(t)}},{key:"hasContentFor",value:function(t){return!!this.transports[t]&&this.getContentFor(t).length>0}},{key:"getSourceFor",value:function(t){return this.transports[t]&&this.transports[t][0].from}},{key:"getContentFor",value:function(t){var e=this.transports[t];if(e)return r(e)}},{key:"getTransportIndex",value:function(t){var e=t.to,n=t.from;for(var r in this.transports[e])if(this.transports[e][r].from===n)return r;return-1}}]),e}(),p=new c(h),d=/^(attrs|props|on|nativeOn|class|style|hook)$/,y=function(t){return t.reduce(function(t,e){var n,r,s,i,a;for(s in e)if(n=t[s],r=e[s],n&&d.test(s))if("class"===s&&("string"==typeof n&&(a=n,t[s]=n={},n[a]=!0),"string"==typeof r&&(a=r,e[s]=r={},r[a]=!0)),"on"===s||"nativeOn"===s||"hook"===s)for(i in r)n[i]=o(n[i],r[i]);else if(Array.isArray(n))t[s]=n.concat(r);else if(Array.isArray(r))t[s]=[n].concat(r);else for(i in r)n[i]=r[i];else t[s]=e[s];return t},{})},g={abstract:!0,name:"portalTarget",props:{attributes:{type:Object,default:function(){return{}}},multiple:{type:Boolean,default:!1},name:{type:String,required:!0},slim:{type:Boolean,default:!1},tag:{type:String,default:"div"},transition:{type:[Boolean,String,Object],default:!1},transitionEvents:{type:Object,default:function(){return{}}}},data:function(){return{transports:p.transports,firstRender:!0}},created:function(){this.transports[this.name]||this.$set(this.transports,this.name,[])},mounted:function(){var t=this;this.unwatch=this.$watch("ownTransports",this.emitChange),this.$nextTick(function(){t.transition&&(t.firstRender=!1)})},beforeDestroy:function(){this.unwatch(),this.$el.innerHTML=""},methods:{emitChange:function(t,e){if(this.multiple)this.$emit("change",[].concat(f(t)),[].concat(f(e)));else{var n=0===t.length?void 0:t[0],r=0===e.length?void 0:e[0];this.$emit("change",l({},n),l({},r))}}},computed:{ownTransports:function(){var t=this.transports[this.name]||[];return this.multiple?t:0===t.length?[]:[t[t.length-1]]},passengers:function(){return r(this.ownTransports)},children:function(){return 0!==this.passengers.length?this.passengers:this.$slots.default||[]},hasAttributes:function(){return Object.keys(this.attributes).length>0},noWrapper:function(){var t=!this.hasAttributes&&this.slim;return t&&this.children.length>1&&console.warn("[portal-vue]: PortalTarget with `slim` option received more than one child element."),t},withTransition:function(){return!!this.transition},transitionData:function(){var t=this.transition,e={};return this.firstRender&&"object"===i(this.transition)&&!this.transition.appear?(e.props={name:"__notranstition__portal-vue__"},e):("string"==typeof t?e.props={name:t}:"object"===(void 0===t?"undefined":i(t))&&(e.props=t),this.renderSlim&&(e.props.tag=this.tag),e.on=this.transitionEvents,e)}},render:function(t){var e=this.noWrapper?"transition":"transition-group",n=this.tag;if(this.withTransition)return t(e,y([this.transitionData,{class:"vue-portal-target"}]),[this.children]);var r=this.ownTransports.length;return this.noWrapper?this.children[0]:t(n,y([{class:"vue-portal-target"},this.attributes,{key:r}]),[this.children])}},m="undefined"!=typeof window,v=1,b={abstract:!0,name:"portal",props:{disabled:{type:Boolean,default:!1},name:{type:String,default:function(){return String(v++)}},order:{type:Number,default:0},slim:{type:Boolean,default:!1},tag:{type:[String],default:"DIV"},targetEl:{type:m?[String,HTMLElement]:String},to:{type:String,default:function(){return String(Math.round(1e7*Math.random()))}}},mounted:function(){this.targetEl&&this.mountToTarget(),this.disabled||this.sendUpdate()},updated:function(){this.disabled?this.clear():this.sendUpdate()},beforeDestroy:function(){this.clear(),this.mountedComp&&this.mountedComp.$destroy()},watch:{to:function(t,e){e&&this.clear(e),this.sendUpdate()},targetEl:function(t,e){t&&this.mountToTarget()}},methods:{sendUpdate:function(){this.$slots.default?p.open({from:this.name,to:this.to,passengers:[].concat(f(this.$slots.default)),order:this.order}):this.clear()},clear:function(t){p.close({from:this.name,to:t||this.to})},mountToTarget:function(){var n=void 0,r=this.targetEl;if("string"==typeof r)n=document.querySelector(r);else{if(!(r instanceof HTMLElement))return void console.warn("[vue-portal]: value of targetEl must be of type String or HTMLElement");n=r}if(n){var o=new t(l({},g,{parent:this,propsData:{name:this.to,tag:n.tagName,attributes:e(n)}}));o.$mount(n),this.mountedComp=o}else console.warn("[vue-portal]: The specified targetEl "+r+" was not found")}},render:function(t){var e=this.$slots.default||[],n=this.tag;return e.length&&this.disabled?e.length<=1&&this.slim?e[0]:t(n,null,[e]):t(n,{class:"v-portal",style:"display: none",key:"v-portal-placeholder"},[])}};return"undefined"!=typeof window&&window.Vue&&window.Vue.use({install:s}),{install:s,Portal:b,PortalTarget:g,Wormhole:p}});
diff --git a/example/index.html b/example/index.html
index 13c756c..a8e7762 100644
--- a/example/index.html
+++ b/example/index.html
@@ -14,7 +14,7 @@ The following content is outside of the control of the Vue main instance
But we can render stuff here nonetheless with the mountTarget Prop
diff --git a/package.json b/package.json
index 8b3c29c..cfc4a08 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "portal-vue",
- "version": "1.2.0",
+ "version": "1.2.1",
"description": "A Vue component to render elements outside of a component's template, elsewhere in the DOM",
"main": "dist/portal-vue.js",
"files": [
diff --git a/src/components/portal-target.js b/src/components/portal-target.js
index aaaf338..ab92a16 100644
--- a/src/components/portal-target.js
+++ b/src/components/portal-target.js
@@ -1,12 +1,12 @@
// import { transports } from './wormhole'
-import { combinePassengers, updateAttributes } from '../utils'
+import { combinePassengers } from '../utils'
import wormhole from './wormhole'
export default {
abstract: true,
name: 'portalTarget',
props: {
- attributes: { type: Object },
+ attributes: { type: Object, default: () => ({}) },
multiple: { type: Boolean, default: false },
name: { type: String, required: true },
slim: { type: Boolean, default: false },
@@ -27,28 +27,18 @@ export default {
},
mounted () {
this.unwatch = this.$watch('ownTransports', this.emitChange)
-
- this.updateAttributes()
this.$nextTick(() => {
if (this.transition) { // only when we have a transition, because it causes a re-render
this.firstRender = false
}
})
},
- updated () {
- this.updateAttributes()
- },
beforeDestroy () {
this.unwatch()
this.$el.innerHTML = ''
},
methods: {
- updateAttributes () {
- if (this.attributes) {
- updateAttributes(this.attributes, this.$el)
- }
- },
emitChange (newTransports, oldTransports) {
if (this.multiple) {
this.$emit('change',
@@ -79,8 +69,11 @@ export default {
children () {
return this.passengers.length !== 0 ? this.passengers : (this.$slots.default || [])
},
+ hasAttributes () {
+ return Object.keys(this.attributes).length > 0
+ },
noWrapper () {
- const noWrapper = !this.attributes && this.slim
+ const noWrapper = !this.hasAttributes && this.slim
if (noWrapper && this.children.length > 1) {
console.warn('[portal-vue]: PortalTarget with `slim` option received more than one child element.')
}
@@ -132,6 +125,6 @@ export default {
return this.noWrapper
? this.children[0]
- :
{this.children}
+ :
{this.children}
},
}
diff --git a/src/utils.js b/src/utils.js
index 13f2138..2775860 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -7,23 +7,21 @@ export function extractAttributes (el) {
attrs[attr.name] = attr.value === '' ? true : attr.value
}
}
- return attrs
-}
-
-export function updateAttributes (attrs, el) {
- // special treatment for class
+ let klass, style
if (attrs.class) {
- attrs.class.trim().split(' ').forEach((klass) => {
- el.classList.add(klass)
- })
+ klass = attrs.class
delete attrs.class
}
-
- const keys = Object.keys(attrs)
-
- for (let i = 0; i < keys.length; i++) {
- el.setAttribute(keys[i], attrs[keys[i]])
+ if (attrs.style) {
+ style = attrs.style
+ delete attrs.style
+ }
+ const data = {
+ attrs,
+ class: klass,
+ style,
}
+ return data
}
export function freeze (item) {
diff --git a/test/unit/specs/portal-target.spec.js b/test/unit/specs/portal-target.spec.js
index 8ad0cb4..1c71c28 100644
--- a/test/unit/specs/portal-target.spec.js
+++ b/test/unit/specs/portal-target.spec.js
@@ -52,9 +52,7 @@ describe('PortalTarget', function () {
passengers: vNode,
},
])
-
const wrapper = createWrapper({ slim: true })
-
expect(wrapper.is('.testnode')).toBe(true)
})