Skip to content

[3.0] Stop calling createEventListener, which no longer exists - #9439

Open
albertlast wants to merge 1 commit into
SimpleMachines:release-3.0from
albertlast:3.0/missing-event-listener-shim
Open

[3.0] Stop calling createEventListener, which no longer exists#9439
albertlast wants to merge 1 commit into
SimpleMachines:release-3.0from
albertlast:3.0/missing-event-listener-shim

Conversation

@albertlast

Copy link
Copy Markdown
Collaborator

Description

588d99d63 ("Remove string evaluations") took the createEventListener() shim out of
script.js and left five calls to it behind. Nothing defines it any more:

Uncaught ReferenceError: createEventListener is not defined

Each call sits at the top of an inline block, so everything after it in that block is
skipped as well. Four pages are affected.

where what stops working
Sources/Profile.php:1455 the submit handler that blocks saving an account without the current password — the alert never appears
Sources/Actions/Admin/Attachments.php:115,117 toggleSubDir() is never bound and never run, so the base-directory and "use subdirectories" rows show whatever the automatically manage attachment directories setting says
Themes/default/PersonalMessage.template.php:772 initSearch() is never bound, so a %u sequence pasted into the PM search box stays escaped
Themes/default/scripts/register.js:55,74 throws inside addVerificationField() and addUsernameSearchTrigger(), which is every live check on the sign-up form

The shim only ever existed for browsers with no addEventListener — 2.1's copy is the
attachEvent fallback — so there is nothing to put back. The calls go.

Checked

Admin → Attachments and Avatars, with automatic management off:

before after
use_subdirectories_for_attachments visible, enabled hidden, disabled
its row shown display: none
basedirectory_for_attachments and its row shown hidden

and switching automatically manage on brings all four back, off hides them again.

Profile → Account Settings with the password field empty: submitting is now cancelled
with "For security reasons, your current password is required to make changes to your
account."
On release-3.0 the event is not cancelled and no alert is raised.

The console error is gone from all three pages I could reach. The sign-up form is read from
the code rather than exercised — registration is off on this install — but it is the same
ReferenceError from a function that runs for every autov field on the form.

Issues References (Fixes|Related|Closes)

n/a

588d99d took the createEventListener() shim out of script.js and left
five calls to it behind. Each one throws a ReferenceError, and since they
all sit at the top of an inline block, everything after them in that
block is skipped:

- Profile.php never reaches the submit handler that stops an account
  being saved without the current password, so that alert never appears.
- The attachment settings page never binds or runs toggleSubDir(), so the
  base directory and "use subdirectories" rows show even when attachment
  directories are not managed automatically.
- The PM search page never binds initSearch(), which unescapes a %u
  sequence pasted into the search box.
- register.js throws inside addVerificationField() and
  addUsernameSearchTrigger(), which is every live check on the sign-up
  form.

The shim only existed for browsers without addEventListener, so there is
nothing to put back; the calls go.

Signed-off-by: Mathias Alberts <mathiaspapealbert@hotmail.com>
Signed-off-by: albertlast <mathiaspapealbert@hotmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant