Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

backbone-childs

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

backbone-childs - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

README.md

46

index.js

@@ -5,11 +5,39 @@ var _ = require('underscore');

/**
* Remove an element and provide a function that inserts it into its original position
* @param element {Element} The element to be temporarily removed
* @return {Function} A function that inserts the element into its original position
**/
function removeToInsertLater(element) {
var parentNode = element.parentNode;
var nextSibling = element.nextSibling;
parentNode.removeChild(element);
return function() {
if (nextSibling) {
parentNode.insertBefore(element, nextSibling);
} else {
parentNode.appendChild(element);
}
};
}
var removeChilds = function (node) {
var last;
while (last = node.lastChild) node.removeChild(last);
};
module.exports = pluginator = viewType.extend({
renderSubviews: function() {
// it is faster to remove the entire element and replace it
// -> however this will lead to lost id,class and style props
var oldEl = this.el;
var el = document.createElement("div");
this.setElement(el);
// it might be that the element is not on the DOM yet
var elOnDom = oldEl.parentNode != undefined;
if(elOnDom){
var insert = removeToInsertLater(oldEl)
}
removeChilds(oldEl);
var frag = document.createDocumentFragment();
if (oldEl.parentNode != null) {
oldEl.parentNode.replaceChild(this.el, oldEl);
}
var views = this._views();

@@ -28,4 +56,8 @@ var viewsSorted = _.sortBy(views, function(el) {

}
el.appendChild(frag);
return el;
oldEl.appendChild(frag);
if(elOnDom){
insert();
}
return oldEl;
},

@@ -32,0 +64,0 @@ addView: function(key, view) {

2

package.json
{
"name": "backbone-childs",
"version": "1.0.2",
"version": "1.0.3",
"description": "Extended backbone view with support for child views",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc