[3.0] Stop the posting form repeating two ids - #9458
Open
albertlast wants to merge 1 commit into
Open
Conversation
The reply form gives every previous post's quote button the same id="post_modify", so a reply to a topic with any history serves a document with that id several times over, and the ajax that appends newly arrived posts adds one more each time. It is only ever reached by a stylesheet, and a stylesheet does not need an id, so it becomes a class and the one rule that names it follows. The attachments area repeats id="attachment1" as well. It draws two file inputs, one for the plain UI and one as the drop zone's fallback, and only ever shows one of them: the plain block is removed by smf_fileUpload.js when the script runs, and the fallback sits inside a container the stylesheet hides until it does. Only the fallback is looked up by id, by the clear link beside it, so the other one gives up its copy. Signed-off-by: Mathias Albert <mathiaspapealbert@hotmail.com> Signed-off-by: albertlast <mathiaspapealbert@hotmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Two ids on the posting form are emitted more than once per document.
post_modifyis on the quote button of every previous post shown below the reply box:<li id="post_modify"><a href="#postmodify" onclick="return insertQuoteFast(', $post['id'], ');">That loop runs once per post, so replying to a topic with any history serves the id several times over — and
$newPostsHTML, the template the page uses to append posts that arrived while you were typing, carries the same id, so each new arrival adds another. Nothing looks it up; the only thing that names it is one stylesheet rule,#post_modify { border-radius: 4px }, and a rule does not need an id. It becomes.post_modify, and the rule follows it.attachment1is on both file inputs in the attachments area. One belongs to the plain UI and one is the drop zone's fallback, and only one of them is ever shown:smf_fileUpload.jsremoves#postAttachmentoutright when it initialises, and when it does not run the fallback stays hidden inside#attachment_previews. The fallback is the one looked up by id —cleanFileInput('attachment1'), the clear link sitting next to it — so the plain one gives up its copy and keeps its name, which is all the server reads.How this was tested
On a local 3.0 install, against
?action=post;topic=1.0and?action=post;board=1.0:post_modify×2 andattachment1×2 before, no repeated id at all after..quickbuttons > lion the reply page measured before and after — position, size, all four border radii, background and display are identical, so the id-to-class swap changes nothing on screen. The attachments area's box is unchanged too.Issues References (Fixes|Related|Closes)
Related: #7933