Add navigate support for replacing html attributes #9149
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The scenario
Currently if you use
wire:navigate
and change to a different page, the new pages<html>
element attributes are not added and the old ones aren't cleaned up.This is noticeable with Flux, when you have a
wire:navigate
link inside a modal. When you open a modal, styles are applied to the<html>
element to stop the page in the background from scrolling. But when you navigate to the new page, the anti-scroll styles are still applied, stopping the page from being scrollable.The problem
The issue is that
wire:navigate
doesn't have any facility for replacing attributes on the<html>
element.The solution
This PR adds support for replacing the page's
<html>
element attributes with the new pages<html>
attributes.I've structured this so it does a comparison between the old and new attributes, and updates the existing ones if there has been a change and removes any that are no longer needed. By doing it this way, we don't trigger any changes for attributes that are the same on both pages.
Fixes livewire/flux#839