Introduce StimulusReflex::HTML::Document, featuring Nokogiri::HTML5#601
Conversation
1b49caf to
3c2f031
Compare
11ab381 to
4dea4e4
Compare
4dea4e4 to
baec564
Compare
|
I've been going over 594 and 601 really carefully the past few days. I'm feeling conflicted because we went from a working solution with predictable behaviour that was entirely self-contained in the two classes that required it, to something that is 80 lines longer, spread out over several classes and requires a lot more mental overhead to follow than what we had. That said, it does seem to be a logical refactoring and most of my initial concerns appear to be addressed. To recap, there was a Nokogiri parsing bug introduced in 594. We originally chose the It seems as though we could have fixed 594 by reverting to the use of Digging into 601, I'm curious/nervous about any potential ramifications from switching page morph processing from Not knowing the minute ways these modules could differ from each other does create some anxiety. For example, according to https://nokogiri.org/rdoc/Nokogiri/HTML5.html the HTML5 module isn't available to JRuby(!!). It also seems as though the HTML5 Should we just stick to the original It seems like with any use of morph "html", render(template: "home/index", layout: true)but this "works", only because the Nokogiri HTML5 fragment parser (see point number one) strips the morph "body", render(template: "home/index", layout: true)While it's uncommon for someone to do this, it's not that weird. I can definitely imagine scenarios where people are rendering pages on demand; if they wanted to implement a navigation system, for example. Should we allow people to render a full HTML document and pass it to a selector morph? I'm picturing dynamically switching between The last thing I'm a bit fuzzy on is that while Marco's |
…age-morphs' into fix-fragment-class-in-combination-with-page-morphs
hopsoft
left a comment
There was a problem hiding this comment.
This PR looks good to me. My only reservation is that we ensure that this doesn't change/break any existing behavior. Having said that, I think we can cross the JRuby bridge if/when we need to in the future.
StimulusReflex::Fragment class in combination with page morphsStimulusReflex::HTML::Document, featuring Nokogiri::HTML5
Type of PR
Bug Fix and Enhancement
Description
Extract fragment logic intoStimulusReflex::HTML::Partand introduceStimulusReflex::HTML::Document(for page morphs) andStimulusReflex::HTML::Fragment(for selector morphs)Edit: After a rework I was able to make page morphs and selector morphs work with just a single
StimulusReflex::HTML::Documentclass.Why should this be added
#594 refactored and simplified some of the logic into a new
StimulusReflex::Fragmentclass. This new class was then also being used for page morphs. Nokogiri fragments produce weird HTML if you pass them a whole HTML document. Since both page and selector morphs were now being passed through Nokogiri fragments this broke the behaviour for page morphs.Example:
Input:
Output:
Interestingly enough,
morphdomwas still able to process this generated HTML without any noticeable issues. Though, this inconsistency should be fixed.For example, the
Alpine.morph()function wasn't able to process the generated HTML. I discovered this inconsistency while working on the CableReadyalpine_morphpackage.Checklist