vue-fragment
Advanced tools
Comparing version 1.2.2 to 1.5.0
@@ -1,1 +0,1 @@ | ||
var directive={inserted:function(e){var n=document.createDocumentFragment(),r=Array.from(e.childNodes),t=e.parentNode,o=document.createComment("fragment tail");n.appendChild(o),r.forEach(function(e){return n.appendChild(e)}),t.insertBefore(n,e),t.removeChild(e),r.forEach(function(n){return freeze(n,e)}),e.__hooks__={appendChild:e.appendChild,insertBefore:e.insertBefore,removeChild:e.removeChild},e.appendChild=function(n){var r=t.insertBefore(n,o);return n.parentNode!==e&&freeze(n,e),r},e.insertBefore=function(n,r){var o=t.insertBefore(n,r);return n.parentNode!==e&&freeze(n,e),o},e.removeChild=function(e){return unfreeze(e),t.removeChild(e)}},unbind:function(e){e.__hooks__&&(Object.keys(e.__hooks__).forEach(function(n){e[n]=e.__hooks__[n]}),delete e.__hooks__)}},freeze=function(e,n){Object.defineProperty(e,"parentNode",{configurable:!0,writable:!1,value:n})},unfreeze=function(e){Object.defineProperty(e,"parentNode",{configurable:!0,writable:!0,value:null})},component={abstract:!0,directives:{fragment:directive},render:function(e){return e("div",{attrs:{class:"v-fragment"},directives:[{name:"fragment"}]},[this.$slots.default])}};function ssr(e,n){"production"!==process.env.NODE_ENV&&console.warn("v-fragment SSR is not implemented yet.")}var Fragment=component,SSR=ssr,Plugin={install:function(e){e.component("fragment",component)}},index={Fragment:component,Plugin:Plugin,SSR:ssr};export default index;export{Fragment,SSR,Plugin}; | ||
function _defineProperty(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function _objectSpread(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{},r=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(t).filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.forEach(function(n){_defineProperty(e,n,t[n])})}return e}var freeze=function(e,n,t){Object.defineProperty(e,n,{configurable:!0,get:function(){return t},set:function(e){console.warn("tried to set frozen property ".concat(n," with ").concat(e))}})},unfreeze=function(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;Object.defineProperty(e,n,{configurable:!0,writable:!0,value:t})},component={abstract:!0,name:"Fragment",props:{name:{type:String,default:function(){return Math.floor(Date.now()*Math.random()).toString(16)}}},mounted:function(){var e=this.$el,n=e.parentNode,t=document.createComment("fragment#".concat(this.name,"#head")),r=document.createComment("fragment#".concat(this.name,"#tail"));n.insertBefore(t,e),n.insertBefore(r,e),e.appendChild=function(t){n.insertBefore(t,r),freeze(t,"parentNode",e)},e.insertBefore=function(t,r){n.insertBefore(t,r),freeze(t,"parentNode",e)},e.removeChild=function(e){n.removeChild(e),unfreeze(e,"parentNode")},Array.from(e.childNodes).forEach(function(n){return e.appendChild(n)}),n.removeChild(e),freeze(e,"parentNode",n),freeze(e,"nextSibling",r.nextSibling);var o=n.insertBefore;n.insertBefore=function(r,i){o.call(n,r,i!==e?i:t)};var i=n.removeChild;n.removeChild=function(a){if(a===e){for(;t.nextSibling!==r;)e.removeChild(t.nextSibling);n.removeChild(t),n.removeChild(r),unfreeze(e,"parentNode"),n.insertBefore=o,n.removeChild=i}else i.call(n,a)}},render:function(e){var n=this,t=this.$slots.default;return t&&t.length&&t.forEach(function(e){return e.data=_objectSpread({},e.data,{attrs:{fragment:n.name}})}),e("div",{attrs:{fragment:this.name}},t)}};function ssr(e,n){"production"!==process.env.NODE_ENV&&console.warn("v-fragment SSR is not implemented yet.")}var Fragment=component,SSR=ssr,Plugin={install:function(e){e.component("fragment",component)}},index={Fragment:component,Plugin:Plugin,SSR:ssr};export default index;export{Fragment,SSR,Plugin}; |
@@ -1,1 +0,1 @@ | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n(e.Fragment={})}(this,function(e){"use strict";var n={inserted:function(e){var n=document.createDocumentFragment(),o=Array.from(e.childNodes),i=e.parentNode,a=document.createComment("fragment tail");n.appendChild(a),o.forEach(function(e){return n.appendChild(e)}),i.insertBefore(n,e),i.removeChild(e),o.forEach(function(n){return t(n,e)}),e.__hooks__={appendChild:e.appendChild,insertBefore:e.insertBefore,removeChild:e.removeChild},e.appendChild=function(n){var r=i.insertBefore(n,a);return n.parentNode!==e&&t(n,e),r},e.insertBefore=function(n,r){var o=i.insertBefore(n,r);return n.parentNode!==e&&t(n,e),o},e.removeChild=function(e){return r(e),i.removeChild(e)}},unbind:function(e){e.__hooks__&&(Object.keys(e.__hooks__).forEach(function(n){e[n]=e.__hooks__[n]}),delete e.__hooks__)}},t=function(e,n){Object.defineProperty(e,"parentNode",{configurable:!0,writable:!1,value:n})},r=function(e){Object.defineProperty(e,"parentNode",{configurable:!0,writable:!0,value:null})},o={abstract:!0,directives:{fragment:n},render:function(e){return e("div",{attrs:{class:"v-fragment"},directives:[{name:"fragment"}]},[this.$slots.default])}};var i=o,a=function(e,n){"production"!==process.env.NODE_ENV&&console.warn("v-fragment SSR is not implemented yet.")},d={install:function(e){e.component("fragment",o)}},f={Fragment:i,Plugin:d,SSR:a};e.Fragment=i,e.SSR=a,e.Plugin=d,e.default=f,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n(e.Fragment={})}(this,function(e){"use strict";function n(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}var t=function(e,n,t){Object.defineProperty(e,n,{configurable:!0,get:function(){return t},set:function(e){console.warn("tried to set frozen property ".concat(n," with ").concat(e))}})},r=function(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;Object.defineProperty(e,n,{configurable:!0,writable:!0,value:t})},o={abstract:!0,name:"Fragment",props:{name:{type:String,default:function(){return Math.floor(Date.now()*Math.random()).toString(16)}}},mounted:function(){var e=this.$el,n=e.parentNode,o=document.createComment("fragment#".concat(this.name,"#head")),i=document.createComment("fragment#".concat(this.name,"#tail"));n.insertBefore(o,e),n.insertBefore(i,e),e.appendChild=function(r){n.insertBefore(r,i),t(r,"parentNode",e)},e.insertBefore=function(r,o){n.insertBefore(r,o),t(r,"parentNode",e)},e.removeChild=function(e){n.removeChild(e),r(e,"parentNode")},Array.from(e.childNodes).forEach(function(n){return e.appendChild(n)}),n.removeChild(e),t(e,"parentNode",n),t(e,"nextSibling",i.nextSibling);var a=n.insertBefore;n.insertBefore=function(t,r){a.call(n,t,r!==e?r:o)};var f=n.removeChild;n.removeChild=function(t){if(t===e){for(;o.nextSibling!==i;)e.removeChild(o.nextSibling);n.removeChild(o),n.removeChild(i),r(e,"parentNode"),n.insertBefore=a,n.removeChild=f}else f.call(n,t)}},render:function(e){var t=this,r=this.$slots.default;return r&&r.length&&r.forEach(function(e){return e.data=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},o=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),o.forEach(function(t){n(e,t,r[t])})}return e}({},e.data,{attrs:{fragment:t.name}})}),e("div",{attrs:{fragment:this.name}},r)}};var i=o,a=function(e,n){"production"!==process.env.NODE_ENV&&console.warn("v-fragment SSR is not implemented yet.")},f={install:function(e){e.component("fragment",o)}},c={Fragment:i,Plugin:f,SSR:a};e.Fragment=i,e.SSR=a,e.Plugin=f,e.default=c,Object.defineProperty(e,"__esModule",{value:!0})}); |
{ | ||
"name": "vue-fragment", | ||
"version": "1.2.2", | ||
"version": "1.5.0", | ||
"description": "fragment component for vuejs", | ||
@@ -5,0 +5,0 @@ "main": "dist/vue-fragment.min.js", |
@@ -49,3 +49,3 @@ # vue-fragment [![npm version](https://badge.fury.io/js/vue-fragment.svg)](https://badge.fury.io/js/vue-fragment) | ||
export const MyComponent { | ||
components: { VFragment }, | ||
components: { Fragment }, | ||
template: ' | ||
@@ -52,0 +52,0 @@ <fragment> |
@@ -1,34 +0,102 @@ | ||
import directive from './directive' | ||
const freeze = (object, property, value) => { | ||
Object.defineProperty(object, property, { | ||
configurable: true, | ||
get() { return value; }, | ||
set(v) { console.warn(`tried to set frozen property ${property} with ${v}`) } | ||
}); | ||
}; | ||
/* | ||
// wait for PR 'assets for functional components' to pass | ||
const unfreeze = (object, property, value = null) => { | ||
Object.defineProperty(object, property, { | ||
configurable: true, | ||
writable: true, | ||
value: value | ||
}); | ||
}; | ||
export default { | ||
functional: true, | ||
directives: { | ||
'fragment': directive | ||
abstract: true, | ||
name: 'Fragment', | ||
props: { | ||
name: { | ||
type: String, | ||
default: () => Math.floor(Date.now() * Math.random()).toString(16) | ||
} | ||
}, | ||
render: function(h, context) { | ||
return h( | ||
'div', { | ||
attrs: { class: 'fragment' }, | ||
directives: [{ name: 'fragment' }] | ||
}, | ||
[context.children] | ||
) | ||
} | ||
} | ||
*/ | ||
export default { | ||
abstract: true, | ||
directives: { 'fragment': directive }, | ||
render: function(h) { | ||
mounted() { | ||
const container = this.$el; | ||
const parent = container.parentNode; | ||
const head = document.createComment(`fragment#${this.name}#head`) | ||
const tail = document.createComment(`fragment#${this.name}#tail`) | ||
parent.insertBefore(head, container) | ||
parent.insertBefore(tail, container) | ||
container.appendChild = (node) => { | ||
parent.insertBefore(node, tail) | ||
freeze(node, 'parentNode', container) | ||
} | ||
container.insertBefore = (node, ref) => { | ||
parent.insertBefore(node, ref) | ||
freeze(node, 'parentNode', container) | ||
} | ||
container.removeChild = (node) => { | ||
parent.removeChild(node) | ||
unfreeze(node, 'parentNode') | ||
} | ||
Array.from(container.childNodes) | ||
.forEach(node => container.appendChild(node)) | ||
parent.removeChild(container) | ||
freeze(container, 'parentNode', parent) | ||
freeze(container, 'nextSibling', tail.nextSibling) | ||
const insertBefore = parent.insertBefore; | ||
parent.insertBefore = (node, ref) => { | ||
insertBefore.call(parent, node, ref !== container ? ref : head) | ||
} | ||
const removeChild = parent.removeChild; | ||
parent.removeChild = (node) => { | ||
if (node === container) { | ||
while(head.nextSibling !== tail) | ||
container.removeChild(head.nextSibling) | ||
parent.removeChild(head) | ||
parent.removeChild(tail) | ||
unfreeze(container, 'parentNode') | ||
parent.insertBefore = insertBefore | ||
parent.removeChild = removeChild | ||
} | ||
else { | ||
removeChild.call(parent, node) | ||
} | ||
} | ||
}, | ||
render(h) { | ||
const children = this.$slots.default | ||
// add fragment attribute on the children | ||
if (children && children.length) | ||
children.forEach(child => | ||
child.data = { ...child.data, attrs: { fragment: this.name } } | ||
) | ||
return h( | ||
'div', { | ||
attrs: { class: 'v-fragment' }, | ||
directives: [{ name: 'fragment' }] | ||
}, | ||
[this.$slots.default] | ||
"div", | ||
{ attrs: { fragment: this.name } }, | ||
children | ||
) | ||
} | ||
} | ||
}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11357
8
148
1