ded / bonzo

library agnostic, extensible DOM utility
Other
1.32k stars 137 forks source link

data() tests & fixes for #48, dim() test tweaks #50

Closed rvagg closed 12 years ago

rvagg commented 12 years ago

ref #48

ded commented 12 years ago

fyi: nice tip for writing commits. type closes #48 in your commit... so that when they get merged, it will automatically close out the issues

rvagg commented 12 years ago

oh, that's neat, will try and remember.

rvagg commented 12 years ago

bump

rvagg commented 12 years ago

I'm going to keep pushing to this branch until you merge or close this PR!

Diff looks scarier than it is. You'll notice that the major changes in src/ are still to fix my original buggy .data() implementation. The other changes are to fix all the cases where Bonzo doesn't do the right thing when one of its functions are called on an empty collection (see #42). There is a big new test set for empty-collection cases that tests absolutely everything and will even test new functions that are introduced after this commit. Functions that take one or more arguments require test-data to be entered so it know what dummy values to pass in and how to check the result. No-arg functions don't need data if they just return this (like .show()), if they return something else then they need test data.

I've also now included an Ender integration into the test suite, the integration tests don't cover enough given how much new stuff is introduced in the bridge. For now I'm just running an Ender object with an empty collection through the same tests (so it tests bonzo([]).*() and also ender([]).*()). There are a few functions on Ender that don't exist on Bonzo and they are picked up properly.

You'll see a bunch of fixes in both bonzo.js and ender.js that have arisen from these new tests, the cases where errors are thrown or the wrong thing happens.

Merging this is going to close 3 issues, is that tempting enough?

rvagg commented 12 years ago

Also, this is related: https://github.com/ender-js/ender-js/pull/8/files

ded commented 12 years ago

ok, this one is not merging now.... and i was finally gonna have a hard look at it

rvagg commented 12 years ago

@nzakas mentioned a neat NoScope tag innerHTML insertion hack on a recent blog post which is perfect for getting more elements through bonzo.create() so I've included those. The only remaining HTML4 tags we can't insert are FRAME FRAMESET HEAD HTML ISINDEX TITLE, plus IE6 doesn't like ABBR and FF 3.6 and below don't like AREA.

Plus I fixed an annoying test-failure bug on IE8 and below that kept on showing up when you reload the test page. Narrowed it down to a stupid domready timing form cache issue so the form reset() is right with the test now.

Plus the recent append() hack for inserting the likes of a <p/> into a <p/> needed a toLowerCase() to actually pass in IE even though the fix was for IE and is working fine!

Plus some other minor items.

rvagg commented 12 years ago

Fixed another bug in data(). When attributes resolves to a falsey value it would come back as null when requested by name (.data('somekey'), but fine for .data().somekey). I've also changed the API rule that non-existant data keys return null, they now return undefined which makes more sense (and takes up less code to implement).

rvagg commented 12 years ago

Latest commit completes the existing partial support for space separated lists of class names in add/remove/hasClass.

rvagg commented 12 years ago

Fixed height(0) and width(0) in ender.js, it was just a falsey check. Now able to test the bridge in the tests btw, $ is raw Bonzo and ender is Bonzo fitted to Ender.

rvagg commented 12 years ago

changed .height() and .width() in ender.js so they now use dim() instead of their own custom function.

ded commented 12 years ago

damn damn. so this is what happens when putting off a PR this long. this will be some good diff reading