question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Duplicate data attributes for nested sprig() calls in template breaking requests, after 1.7.0 to 1.10.2 update

See original GitHub issue

Describe 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:

  1. Create sprig1.twig with: {{ sprig(‘sprig2.twig’) }}
  2. Create sprig2.twig with: {{ sprig(‘elements.twig’) }}
  3. Create elements.twig with: <button sprig s-method="post" s-action="/test">Sprig test</button>
  4. 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:closed
  • Created 2 years ago
  • Comments:13

github_iconTop GitHub Comments

2reactions
bencrokercommented, Oct 25, 2021

Released the fix in Sprig Core 1.1.5 which you can get by running composer update.

1reaction
bossanova808commented, Oct 22, 2021

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!!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found