Duplicate data attributes for nested sprig() calls in template breaking requests, after 1.7.0 to 1.10.2 update
See original GitHub issueDescribe the bug
After updating to latest version of sprig from 1.7.0 to 1.10.2, elements which are marked for processing by sprig now have duplicate data-hx-* attributes causing requests to fail. This happens if the element is inside a sprig template which is called by sprig() from another sprig template.
To reproduce
Steps to reproduce the behaviour:
- Create sprig1.twig with: {{ sprig(‘sprig2.twig’) }}
- Create sprig2.twig with: {{ sprig(‘elements.twig’) }}
- Create elements.twig with:
<button sprig s-method="post" s-action="/test">Sprig test</button>
- View source and multiple data-hx-* attributes are shown and the expected button functionality fails
Expected behaviour
No duplicate attributes and functioning button
Source
sprig1.twig:
<h1>This is a top level sprig template</h1>
{{ sprig('test/sprig2') }}
sprig2.twig:
<h2>This is a second level sprig template</h2>
{{ sprig('test/buttons') }}
buttons.twig:
<p>These are buttons which have duplicate attributes. View source.</p>
<button sprig s-method="post" s-action="/tests">Sprig test button</button>
Versions
- Plugin version: 1.10.2
- Craft version: 3.7.17.1
Issue Analytics
- State:
- Created 2 years ago
- Comments:13
Top Results From Across the Web
RoR nested attributes produces duplicates when edit
Using cocoon gem on Rails 4, I was still getting duplicate fields even after adding :id to the permitted list when editing. Noticed...
Read more >cookiecutter Documentation
A command-line utility that creates projects from cookiecutters (project templates), e.g. creating a Python package project from a Python ...
Read more >Changelog - Spring
#2263 - Update repository after GitHub issues migration. ... PersistentPropertyPathAccessor does not skip nested null intermediates when setting values.
Read more >Release Notes Red Hat JBoss Fuse 6.3
Since JBoss Fuse 6.3, the JBoss Fuse Maven artifacts are available ... When using the Apache Karaf container with IBM Java version 1.7.0, ......
Read more >Untitled
Initial packaging - Add requires on OpenJDK - Update README - Add missing requires on ... Deduplicate documentation files in unversioned docdir (#1001276)....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Released the fix in Sprig Core 1.1.5 which you can get by running
composer update
.Thanks Ben. I won’t be able to try it out till Monday I’m afraid. Will let you know but I am sure you are right…surprised PHPStorm didn’t ding me on that stray space!!