Skip to content

Commit

Permalink
fix: build error (buble sigh)
Browse files Browse the repository at this point in the history
  • Loading branch information
Caleb Roseland committed Jan 18, 2017
1 parent 8303708 commit 77abdab
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 68 deletions.
63 changes: 33 additions & 30 deletions dist/vue-dom-portal.common.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
/*!
* vue-dom-portal v0.1.1
* vue-dom-portal v0.1.4
* (c) 2017 Caleb Roseland
* Released under the MIT License.
*/
'use strict';

/**
* Get target DOM Node
* @param {(Node|string|Boolean)} [node=document.body] DOM Node, CSS selector, or Boolean
* @return {Node} The target that the el will be appended to
*/
function getTarget (node) {
if ( node === void 0 ) node = document.body;
Expand All @@ -18,45 +20,46 @@ function getTarget (node) {
var homes = new Map();

var directive = {
inserted: function inserted (el, ref, ref$1) {
inserted: function inserted (el, ref, vnode) {
var value = ref.value;
var key = ref$1.key;

// el is home
var parentNode = el.parentNode;
var home = document.createComment();

parentNode.replaceChild(home, el); // moving out, el is no longer in the document

if (!homes.has(key)) { homes.set(key, { parentNode: parentNode, home: home }); } // remember where home is
var home = document.createComment('');
var hasMovedOut = false;

if (value !== false) {
getTarget(value).appendChild(el); // moving out
parentNode.replaceChild(home, el); // moving out, el is no longer in the document
getTarget(value).appendChild(el); // moving into new place
hasMovedOut = true;
}
},
update: function update (el, ref, ref$1) {
var value = ref.value;
var key = ref$1.key;

var ref$2 = homes.get(key);
var parentNode = ref$2.parentNode;
var home = ref$2.home;

if (value === false) {
parentNode.replaceChild(el, home); // moving home
homes.delete(key); // no need to remember anymore
} else {
getTarget(value).appendChild(el); // moving somewhere else
}
if (!homes.has(el)) { homes.set(el, { parentNode: parentNode, home: home, hasMovedOut: hasMovedOut }); } // remember where home is or should be
},
unbind: function unbind (el, binding, ref) {
var key = ref.key;

var ref$1 = homes.get(key);
componentUpdated: function componentUpdated (el, ref) {
var value = ref.value;
// need to make sure children are done updating (vs. `update`)
var ref$1 = homes.get(el);
var parentNode = ref$1.parentNode;
var home = ref$1.home;
parentNode.replaceChild(el, home); // moving home
homes.delete(key); // no need to remember anymore
var hasMovedOut = ref$1.hasMovedOut; // recall where home is

if (!hasMovedOut && value) {
// never moved out on initial insert; value must have started out false
parentNode.replaceChild(home, el);
getTarget(value).appendChild(el); // moving into new place
homes.set(el, Object.assign.apply(Object, [ {} ].concat( homes.get(el), [{ hasMovedOut: true }] ))); // indicate that we've moved out
} else if (hasMovedOut && value === false) {
// already moved out, moving back home
parentNode.replaceChild(el, home);
homes.set(el, Object.assign({}, homes.get(el), { hasMovedOut: false })); // indicate that we've moved back home
// homes.delete(el)
} else if (value) {
// already moved out, moving somewhere else
getTarget(value).appendChild(el);
}
},
unbind: function unbind (el, binding) {
homes.delete(el); // no need to remember anymore
}
};

Expand Down
63 changes: 33 additions & 30 deletions dist/vue-dom-portal.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* vue-dom-portal v0.1.1
* vue-dom-portal v0.1.4
* (c) 2017 Caleb Roseland
* Released under the MIT License.
*/
Expand All @@ -11,6 +11,8 @@

/**
* Get target DOM Node
* @param {(Node|string|Boolean)} [node=document.body] DOM Node, CSS selector, or Boolean
* @return {Node} The target that the el will be appended to
*/
function getTarget (node) {
if ( node === void 0 ) node = document.body;
Expand All @@ -22,45 +24,46 @@ function getTarget (node) {
var homes = new Map();

var directive = {
inserted: function inserted (el, ref, ref$1) {
inserted: function inserted (el, ref, vnode) {
var value = ref.value;
var key = ref$1.key;

// el is home
var parentNode = el.parentNode;
var home = document.createComment();

parentNode.replaceChild(home, el); // moving out, el is no longer in the document

if (!homes.has(key)) { homes.set(key, { parentNode: parentNode, home: home }); } // remember where home is
var home = document.createComment('');
var hasMovedOut = false;

if (value !== false) {
getTarget(value).appendChild(el); // moving out
parentNode.replaceChild(home, el); // moving out, el is no longer in the document
getTarget(value).appendChild(el); // moving into new place
hasMovedOut = true;
}
},
update: function update (el, ref, ref$1) {
var value = ref.value;
var key = ref$1.key;

var ref$2 = homes.get(key);
var parentNode = ref$2.parentNode;
var home = ref$2.home;

if (value === false) {
parentNode.replaceChild(el, home); // moving home
homes.delete(key); // no need to remember anymore
} else {
getTarget(value).appendChild(el); // moving somewhere else
}
if (!homes.has(el)) { homes.set(el, { parentNode: parentNode, home: home, hasMovedOut: hasMovedOut }); } // remember where home is or should be
},
unbind: function unbind (el, binding, ref) {
var key = ref.key;

var ref$1 = homes.get(key);
componentUpdated: function componentUpdated (el, ref) {
var value = ref.value;
// need to make sure children are done updating (vs. `update`)
var ref$1 = homes.get(el);
var parentNode = ref$1.parentNode;
var home = ref$1.home;
parentNode.replaceChild(el, home); // moving home
homes.delete(key); // no need to remember anymore
var hasMovedOut = ref$1.hasMovedOut; // recall where home is

if (!hasMovedOut && value) {
// never moved out on initial insert; value must have started out false
parentNode.replaceChild(home, el);
getTarget(value).appendChild(el); // moving into new place
homes.set(el, Object.assign.apply(Object, [ {} ].concat( homes.get(el), [{ hasMovedOut: true }] ))); // indicate that we've moved out
} else if (hasMovedOut && value === false) {
// already moved out, moving back home
parentNode.replaceChild(el, home);
homes.set(el, Object.assign({}, homes.get(el), { hasMovedOut: false })); // indicate that we've moved back home
// homes.delete(el)
} else if (value) {
// already moved out, moving somewhere else
getTarget(value).appendChild(el);
}
},
unbind: function unbind (el, binding) {
homes.delete(el); // no need to remember anymore
}
};

Expand Down
4 changes: 2 additions & 2 deletions dist/vue-dom-portal.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/en/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ <h1 class="search-results-title">No results matching "<span class='search-query'
<script>
var gitbook = gitbook || [];
gitbook.push(function() {
gitbook.page.hasChanged({"page":{"title":"Introduction","level":"1.1","depth":1,"next":{"title":"Installation","level":"1.2","depth":1,"path":"installation.md","ref":"installation.md","articles":[]},"dir":"ltr"},"config":{"plugins":["edit-link","theme-vuejs@git+https://github.com/pearofducks/gitbook-plugin-theme-vuejs.git","-fontsettings","github","[email protected]"],"root":"./","styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"github":{"url":"https://github.com/calebroseland/vue-dom-portal/"},"search":{},"theme-vuejs":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"highlight":{},"advanced-emoji":{"embedEmojis":false},"sharing":{"facebook":false,"twitter":false,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"edit-link":{"label":"Edit This Page","base":"https://github.com/calebroseland/vue-dom-portal/tree/dev/gitbook"},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"language":"en","links":{"sharing":{"facebook":false,"twitter":false}},"gitbook":"*"},"file":{"path":"README.md","mtime":"2017-01-18T06:39:22.167Z","type":"markdown"},"gitbook":{"version":"3.2.2","time":"2017-01-18T20:55:18.259Z"},"basePath":".","book":{"language":"en"}});
gitbook.page.hasChanged({"page":{"title":"Introduction","level":"1.1","depth":1,"next":{"title":"Installation","level":"1.2","depth":1,"path":"installation.md","ref":"installation.md","articles":[]},"dir":"ltr"},"config":{"plugins":["edit-link","theme-vuejs@git+https://github.com/pearofducks/gitbook-plugin-theme-vuejs.git","-fontsettings","github","[email protected]"],"root":"./","styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"github":{"url":"https://github.com/calebroseland/vue-dom-portal/"},"search":{},"theme-vuejs":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"highlight":{},"advanced-emoji":{"embedEmojis":false},"sharing":{"facebook":false,"twitter":false,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"edit-link":{"label":"Edit This Page","base":"https://github.com/calebroseland/vue-dom-portal/tree/dev/gitbook"},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"language":"en","links":{"sharing":{"facebook":false,"twitter":false}},"gitbook":"*"},"file":{"path":"README.md","mtime":"2017-01-18T06:39:22.167Z","type":"markdown"},"gitbook":{"version":"3.2.2","time":"2017-01-18T21:16:34.881Z"},"basePath":".","book":{"language":"en"}});
});
</script>
</div>
Expand Down
2 changes: 1 addition & 1 deletion docs/en/installation.html
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ <h1 class="search-results-title">No results matching "<span class='search-query'
<script>
var gitbook = gitbook || [];
gitbook.push(function() {
gitbook.page.hasChanged({"page":{"title":"Installation","level":"1.2","depth":1,"previous":{"title":"Introduction","level":"1.1","depth":1,"path":"README.md","ref":"README.md","articles":[]},"dir":"ltr"},"config":{"plugins":["edit-link","theme-vuejs@git+https://github.com/pearofducks/gitbook-plugin-theme-vuejs.git","-fontsettings","github","[email protected]"],"root":"./","styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"github":{"url":"https://github.com/calebroseland/vue-dom-portal/"},"search":{},"theme-vuejs":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"highlight":{},"advanced-emoji":{"embedEmojis":false},"sharing":{"facebook":false,"twitter":false,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"edit-link":{"label":"Edit This Page","base":"https://github.com/calebroseland/vue-dom-portal/tree/dev/gitbook"},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"language":"en","links":{"sharing":{"facebook":false,"twitter":false}},"gitbook":"*"},"file":{"path":"installation.md","mtime":"2017-01-18T04:25:53.091Z","type":"markdown"},"gitbook":{"version":"3.2.2","time":"2017-01-18T20:55:18.259Z"},"basePath":".","book":{"language":"en"}});
gitbook.page.hasChanged({"page":{"title":"Installation","level":"1.2","depth":1,"previous":{"title":"Introduction","level":"1.1","depth":1,"path":"README.md","ref":"README.md","articles":[]},"dir":"ltr"},"config":{"plugins":["edit-link","theme-vuejs@git+https://github.com/pearofducks/gitbook-plugin-theme-vuejs.git","-fontsettings","github","[email protected]"],"root":"./","styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"github":{"url":"https://github.com/calebroseland/vue-dom-portal/"},"search":{},"theme-vuejs":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"highlight":{},"advanced-emoji":{"embedEmojis":false},"sharing":{"facebook":false,"twitter":false,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"edit-link":{"label":"Edit This Page","base":"https://github.com/calebroseland/vue-dom-portal/tree/dev/gitbook"},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"language":"en","links":{"sharing":{"facebook":false,"twitter":false}},"gitbook":"*"},"file":{"path":"installation.md","mtime":"2017-01-18T04:25:53.091Z","type":"markdown"},"gitbook":{"version":"3.2.2","time":"2017-01-18T21:16:34.881Z"},"basePath":".","book":{"language":"en"}});
});
</script>
</div>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "vue-dom-portal",
"description": "An escape hatch directive for DOM Elements in Vue.js components.",
"version": "0.1.3",
"version": "0.1.4",
"author": {
"name": "Caleb Roseland",
"email": "[email protected]"
Expand Down
6 changes: 3 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ const directive = {
// never moved out on initial insert; value must have started out false
parentNode.replaceChild(home, el)
getTarget(value).appendChild(el) // moving into new place
homes.set(el, { ...homes.get(el), hasMovedOut: true }) // indicate that we've moved out
homes.set(el, Object.assign({}, ...homes.get(el), { hasMovedOut: true })) // indicate that we've moved out
} else if (hasMovedOut && value === false) {
// already moved out, moving back home
parentNode.replaceChild(el, home)
homes.set(el, { ...homes.get(el), hasMovedOut: false }) // indicate that we've moved back home
homes.set(el, Object.assign({}, homes.get(el), { hasMovedOut: false })) // indicate that we've moved back home
// homes.delete(el)
} else if (value) {
// already moved out, moving somewhere else
Expand All @@ -51,7 +51,7 @@ function plugin (Vue, { name = 'dom-portal' } = {}) {
Vue.directive(name, directive)
}

plugin.version = '0.1.2'
plugin.version = '0.1.4'

export default plugin

Expand Down

0 comments on commit 77abdab

Please sign in to comment.