Repository navigation
fix(pug-code-gen): apply doctype before compiling tags declared above it - #3482
cdytotoro-ctrl wants to merge 1 commit into
Conversation
Terse mode was only enabled when the Doctype node was reached during the AST walk, so tags compiled before the doctype in document order (mixins declared above 'doctype html', templates with content above the doctype, or mixins in a child template rendered through an extends layout) compiled boolean attributes in non-terse mode (Fixes pugjs#1918). The compiler now pre-applies the first doctype found in the AST before walking it, using the same logic as visitDoctype, which re-applies the same settings later without any effect. Doctypes other than html5 and templates without a doctype keep the previous behavior. Fixes pugjs#1918
|
There is no change log for this pull request yet. |
|
Thanks for picking up this old one! I tested it against master ( #1918 is fixed in every form I tried. On master and 3.0.4 these all render
Changes I'd ask for:
Output changes worth naming in the changelog, all because the first doctype now applies from the first tag on:
Tests:
Rolling Versions still says there is no changelog entry. Something like this for With 1, 2 and the changelog sorted out, this looks good to merge to me. |
Terse mode was only enabled when the Doctype node was reached during the AST walk, so tags compiled before the doctype in document order (mixins declared above 'doctype html', content above the doctype, or mixins in a child template rendered through an extends layout) compiled boolean attributes in non-terse mode (Fixes #1918).
The compiler now pre-applies the first doctype found in the AST before walking it, using the same logic as visitDoctype, which re-applies the same settings later without any effect. Doctypes other than html5 and templates without a doctype keep the previous behavior.
Tests: new test case mixin-above-doctype reproduces the mixin-after-extends scenario from the issue and asserts terse boolean attributes.