eleventy icon indicating copy to clipboard operation
eleventy copied to clipboard

The IdAttributePlugin can create conflicts

Open vrugtehagel opened this issue 1 year ago • 1 comments

Operating system

macOS Sonoma 14.6.1

Eleventy

3.0.0-beta.1

Describe the bug

The plugin does not check for existing id attributes in the markup, only ones created for headers previously. That means the following markup (from a real example):

<section id="thank-you">
  <h2>Thank you!</h2>
  <p>…</p>
</section>

Will output

<section id="thank-you">
  <h2 id="thank-you">Thank you!</h2>
  <p>…</p>
</section>

Solutions

There are two solutions I can think of:

  1. Allow users to opt-out (or in) on a per-page basis. Ones of the sites I manage had two occurrances of clashing id attributes as a result of adding this plugin, but many pages don't actually need the ids for the headers. It'd be nice if I could opt-in on a per-page basis, so that these issues would be less prevalent.
  2. Alternatively, and I recognize this might be more computationally expensive; check the entire page HTML for id attributes to avoid the conflicts.

vrugtehagel avatar Aug 26 '24 07:08 vrugtehagel

Fixed in #3430

zachleat avatar Sep 03 '24 17:09 zachleat

Upstream #3363

zachleat avatar Sep 20 '24 21:09 zachleat