Socket
Socket
Sign inDemoInstall

ampersand-view-switcher

Package Overview
Dependencies
9
Maintainers
4
Versions
17
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.1 to 1.1.2

1

ampersand-view-switcher.js

@@ -107,2 +107,3 @@ /*$AMPERSAND_VERSION*/

view.remove();
if (cb) cb();
});

@@ -109,0 +110,0 @@ } else {

2

package.json
{
"name": "ampersand-view-switcher",
"description": "A utility for swapping out views inside a container element.",
"version": "1.1.1",
"version": "1.1.2",
"author": "Henrik Joreteg <henrik@andyet.net>",

@@ -6,0 +6,0 @@ "browserify": {

@@ -5,11 +5,14 @@ var test = require('tape');

var makeTestView = function(options) {
options = options || {};
return View.extend({
template: '<div data-hook="container"></div>',
autoRender: true,
render: function () {
this.renderWithTemplate();
this.switcher = new ViewSwitcher(this.queryByHook('container'), options);
}
});
};
var TestView = View.extend({
template: '<div data-hook="container"></div>',
render: function () {
this.renderWithTemplate();
this.switcher = new ViewSwitcher(this.queryByHook('container'));
}
});
var ItemView = View.extend({

@@ -26,6 +29,6 @@ template: '<a>hey</a>',

test('basics', function (t) {
var base = new TestView();
var Base = makeTestView();
var base = new Base();
var c1 = new ItemView();
var c2 = new ItemView();
base.render();
t.ok(base.el);

@@ -41,11 +44,4 @@ base.switcher.set(c1);

var count = 0;
var NewView = TestView.extend({
render: function () {
this.renderWithTemplate();
this.switcher = new ViewSwitcher(this.queryByHook('container'), {
empty: function () {
count++;
}
});
}
var NewView = makeTestView({
empty: function () { count++; }
});

@@ -55,3 +51,2 @@ var c1 = new ItemView();

var base = new NewView();
base.render();
t.equal(count, 1, 'should be called at first');

@@ -68,4 +63,6 @@ base.switcher.set(c1);

test('self inserting views can be set without throwing exceptions', function (t) {
var base = new TestView();
var Base = makeTestView();
var base = new Base();
var v1 = new SelfInsertingView();
console.log(base);
base.render();

@@ -77,1 +74,38 @@ t.doesNotThrow(function() {

});
test('`options.hide', function(t) {
t.plan(4);
var TestView = makeTestView({
hide: function(oldView, newView) {
t.equal(oldView, c1, 'first param should be previous view');
t.equal(newView, c2, 'second param should be current view');
}
});
var base = new TestView();
var c1 = new ItemView();
var c2 = new ItemView();
base.switcher.set(c1);
base.switcher.set(c2);
t.equal(c1.el.parentNode, null, 'the previous view was removed');
t.equal(base.el.firstChild, c2.el, 'the current view was set');
});
test('`option.hide` with `waitForRemove`', function(t) {
t.plan(5);
var TestView = makeTestView({
waitForRemove: true,
hide: function(oldView, newView, cb) {
t.equal(oldView, c1, 'first param should be previous view');
t.equal(newView, c2, 'second param should be current view');
t.ok(typeof cb === 'function', "third param is callback");
cb();
}
});
var base = new TestView();
var c1 = new ItemView();
var c2 = new ItemView();
base.switcher.set(c1);
base.switcher.set(c2);
t.equal(c1.el.parentNode, null, 'the previous view was removed');
t.equal(base.el.firstChild, c2.el, 'the current view was set');
});
SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc