Re-add afterLoad to loadNote to improve compatibility#1326
Closed
chriszs wants to merge 1 commit into
Closed
Conversation
Closes MuckRock#1325 Co-authored-by: Copilot <copilot@github.com>
a87e72a to
c193cc6
Compare
Author
|
Closing until I can work out how to fire this once the iframe is done resizing. |
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.
Adds an optional
optsargument toloadNoteinnoteLoader.js, which accepts anafterLoadcallback and fires it after the noteiframeemits a load event and passes an object with a single propertyelcontaining the note's containing element. This is a restoration of a part of the originalloadNote's API to improve compatibility with historic custom journalism, which used this to render notes as inline document cite overlays.The original fired after calling
render()on the note, which set its innerHTML. It's a choice to treat the iframe load event as the equivalent (as opposed to say, a resize event). Because we're setting this in a loop, it's a possibility this would call multiple times if the same note were to be rendered multiple times in a document. The original passed anoteobject, which in addition toelalso exposedrender()andsetElement()as well as some other methods. It's possible that code that depended on one of those would break with this shim, but I'm choosing not to add those at this point.In local testing, appears to solve the issue posed by the legacy ProPublica piece which prompted this PR.
Closes #1325