Giter VIP home page Giter VIP logo

Comments (5)

adam12 avatar adam12 commented on June 7, 2024

I solved it (albeit hackish) with the following diff. It would probably make more sense to copy the class attr off of the new body from the XHR request, but I wasn't sure where I could gain access to it.

diff --git a/lib/assets/javascripts/unpoly/dom.coffee b/lib/assets/javascripts/unpoly/dom.coffee
index c3fcb81..9f7ab78 100644
--- a/lib/assets/javascripts/unpoly/dom.coffee
+++ b/lib/assets/javascripts/unpoly/dom.coffee
@@ -507,6 +507,7 @@ up.dom = (($) ->

   # This is a separate method so we can mock it in specs
   swapBody = ($oldBody, $newBody) ->
+    $newBody.attr('class', $oldBody.attr('class')).removeClass('up-destroying')
     $oldBody.replaceWith($newBody)

   transferKeepableElements = ($old, $new, options) ->

from unpoly.

triskweline avatar triskweline commented on June 7, 2024

We should not try to keep attributes from the old <body>, this would be inconsistent with how fragment replacement works anywhere else. Instead the attributes from the new <body> in the response should be used.

I think the bug is here:

createElementFromHtml = (html) ->

This is code that parses full HTML pages from the response. jQuery can make a DOM from most strings, but not strings that contain <html> or <body> tags.

We could fix that code. Or maybe drop IE9 support and use DOMParser.

from unpoly.

triskweline avatar triskweline commented on June 7, 2024

Fixed in 0.35.0.

from unpoly.

adam12 avatar adam12 commented on June 7, 2024

Works :) Thanks!

(I had to build from master as I noticed dist/ was out of date, as well as CDN, just FYI)

from unpoly.

triskweline avatar triskweline commented on June 7, 2024

Oops, forgot to update dist/, CDN and npm. Did that now. Thanks for the hint!

from unpoly.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.