MoOx / pjax

Easily enable fast Ajax navigation on any website (using pushState + xhr)
MIT License
1.46k stars 125 forks source link

Add examples, remove failing test #44

Closed rstacruz closed 9 years ago

rstacruz commented 9 years ago

This adds examples to /example. This shows that the plugin right now is at a state that doesn't actually work:

pasted_image_11_13_15__10_44_am

I've removed the failing test now so the test suite should pass, but that's no indicator that the project is in a working state.

rstacruz commented 9 years ago

also some breakages I've found: this IE workaround actually breaks things because el in this case is the document root element (<html>), which can't be inserted into the document.body of course.

     forEachEls(els, function(el) {
       var domFix = false
-      if (!el.parentNode) {
         // THANKS YOU IE (9/10//11 concerned)
         // dispatchEvent doesn't work if element is not in the dom
-        domFix = true
-        document.body.appendChild(el)
-      }
       el.dispatchEvent(event)
-      if (domFix) {
-        el.parentNode.removeChild(el)
-      }
     })
rstacruz commented 9 years ago

Another: onSwitch is not available here because this isn't what you think it is—it's probably simply missing a .bind somewhere.

module.exports = {
  outerHTML: function(oldEl, newEl) {
    oldEl.outerHTML = newEl.outerHTML
-   this.onSwitch()
  },

  innerHTML: function(oldEl, newEl) {
    oldEl.innerHTML = newEl.innerHTML
    oldEl.className = newEl.className
-   this.onSwitch()
  },
MoOx commented 9 years ago

I guess the hirerarchy error come from the IE workaround :/ For the onSwitch, it's probably because I didn't finish what I started.

MoOx commented 9 years ago

That why I added a failing test, to remember where to continue :)

rstacruz commented 9 years ago

okay—removed the removal of that test, so it should fail now. this PR should at least give you a nice example to replicate #39.

MoOx commented 9 years ago

Thanks for this.