Эх сурвалжийг харах

Give file posts a unique postData id, and drop the duplicate class attribute

file.tx emitted <div class="postData" id="postData" class="responsive-text">.
The second class attribute is silently discarded by every browser, so the
responsive-text styling never applied, and the id was shared by every file post
on a page rather than being suffixed with the post id like every other form
does. Matches blog/microblog/entities/invoice now.

The series lifecycle test asserts both the unique id and the absence of the
duplicate attribute, and fails against the old markup.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01U3k2hhSZpcsoe6uBmhF9nB
George Baugh 2 сар өмнө
parent
commit
43819814b2

+ 6 - 0
t/Trog-Routes-HTML-series-lifecycle.t

@@ -586,8 +586,14 @@ subtest 'file' => sub {
     my $body = _series_page( 'file', 'specfile', $title, 1 ) or return;
 
     like( $body, qr{href='/assets/\Q$child->{id}\E\.spec-upload\.txt'}, 'title links to the asset' );
+    like( $body, qr{id="postData-\Q$child->{id}\E"}, 'body block carries a unique id, like every other form' );
     like( $body, qr/Spec file body\./, 'body text rendered' );
 
+    # This form used to emit <div class="postData" id="postData" class="responsive-text">
+    # -- a duplicated class attribute, and an id shared by every file post on
+    # the page.  Neither should come back.
+    unlike( $body, qr{<div class="postData" id="postData"}, 'no duplicated class attribute' );
+
     # text/plain, so none of the media branches fire.
     unlike( $body, qr/<video/, 'no video block for a text file' );
     unlike( $body, qr/<audio/, 'no audio block either' );

+ 1 - 1
www/templates/html/components/forms/file.tx

@@ -34,7 +34,7 @@
         : }
 
         : if( $post.data ) {
-            <div class="postData" id="postData" class="responsive-text">
+            <div class="postData responsive-text" id="postData-<: $post.id :>">
             : if ( $style != 'media' ) {
                 <: render_it($post.data) | mark_raw  :>
             : }