Skip to content

Commit

Permalink
remove hide and show
Browse files Browse the repository at this point in the history
These are broken by design and better done with adding and removing
classes. Classes are a more flexible approach that can be styled easier.
  • Loading branch information
defunctzombie committed Jan 19, 2013
1 parent f181a6c commit 734998f
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 47 deletions.
28 changes: 1 addition & 27 deletions index.js
Expand Up @@ -28,7 +28,7 @@ function dom(selector, context) {
}

// array
if (Array.isArray(selector)) {
if (selector instanceof Array) {
return new List(selector);
}

Expand Down Expand Up @@ -235,32 +235,6 @@ proto.html = function(val){
return el.innerHTML;
};

proto.hide = function() {
this.forEach(function(item) {
var save = item.style.display;
if (save) {
item.setAttribute('data-olddisplay', save);
}
item.style.display = 'none';
});
return this;
};

proto.show = function() {
this.forEach(function(item) {
var old = item.getAttribute('data-olddisplay');
item.removeAttribute('data-olddisplay');

// use default display for element
if (!old || old === 'none') {
old = '';
}

item.style.display = old;
});
return this;
};

/**
* Bind to `event` and invoke `fn(e)`. When
* a `selector` is given then events are delegated.
Expand Down
20 changes: 0 additions & 20 deletions test/css.js
Expand Up @@ -55,23 +55,3 @@ test('.css(obj)', function() {
assert('absolute' == list[0].style.position);
});

test('.hide()', function() {
var div = dom('<div></div>');
div.hide();
assert('none' == div[0].style.display);
});

test('.show()', function() {
var div = dom('<div style="display:none">f</div>');
div.show();
assert.equal('', div[0].style.display);
});

test('.show() - preserve previous', function() {
var div = dom('<div style="display:table"></div>');
div.hide();
assert('none' == div[0].style.display);
div.show();
assert('table' == div[0].style.display);
});

0 comments on commit 734998f

Please sign in to comment.