Skip to content

Script tag is injected in the wrong place (in the middle of body's attribute list) #2008

Open
@pmpinto

Description

@pmpinto

Issue details

So, I'm using 11ty, which comes bundled with browser-sync by default.
All good so far.
But I'm also using Stimulus, which relies on a specific syntax to set actions: https://stimulus.hotwired.dev/reference/actions

It looks to me like browser-sync is looking for the first > char, right after <body to inject the script tag — but I could be wrong. And as you can see, when using Stimilus and using the <body> element as a Stimulus controller, it can cause some issues.

Steps to reproduce/test case

  1. Set up a simple 11ty website
  2. Add an attribute to the body tag such as data-action="access:notify->notification#show" — I believe you can avoid setting up Stimulus altogether
  3. Witness the body tag get messed up as follows:
    Source:
    <body class="home" data-controller="application" data-action="access:notify->notification#show">
    Result:
    Screenshot 2023-01-24 at 18 25 35

Please specify which version of Browsersync, node and npm you're running

  • Browsersync v2.27.11
  • Node v18.12.0
  • Npm v8.19.2

Affected platforms

  • linux
  • windows
  • OS X
  • freebsd
  • solaris
  • other (please specify which)

Browsersync use-case

  • API — I suppose, it's the default 11ty integration
  • Gulp
  • Grunt
  • CLI

for all other use-cases, (gulp, grunt etc), please show us exactly how you're using Browsersync

{Browsersync init code here}

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions