Cdentinger has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/297729

Change subject: Use RL to make RapidHTML wait for document ready
......................................................................

Use RL to make RapidHTML wait for document ready

This is probably an unacceptably bad user experience because at least on
vagrant there is a visual repaint as the js applies the new styles.

Bug: T139551
Change-Id: I724a033088e4ee0b0fb203ee0054dfc328b6c2bc
---
M gateway_forms/RapidHtml.php
1 file changed, 19 insertions(+), 0 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DonationInterface 
refs/changes/29/297729/1

diff --git a/gateway_forms/RapidHtml.php b/gateway_forms/RapidHtml.php
index fed21b4..303da17 100644
--- a/gateway_forms/RapidHtml.php
+++ b/gateway_forms/RapidHtml.php
@@ -157,6 +157,25 @@
        public function getForm() {
                $html = $this->load_html();
                $html = $this->replace_blocks( $html );
+
+               // Since 1.26 one can no longer count on mw being available
+               // before document ready. Need to wrap these calls with RL.
+               $dom = new DOMDocument();
+               $dom->loadHTML($html);
+               // Get the first script from the partial.
+               $oldnode = $dom->getElementsByTagName('script')->item(0);
+               // Get the script value (no tags).
+               $script = $oldnode->nodeValue;
+               // Add RLQ voodoo (also adds script tags).
+               $script = ResourceLoader::makeInlineScript( $script );
+               // Remove the tags as DomDoc won't print literals.
+               $script = substr( $script, 8 );
+               $script = substr( $script, 0, -9 );
+               // Make the new node and insert it.
+               $newnode = $dom->createElement( 'script', $script );
+               $oldnode->parentNode->replaceChild( $newnode, $oldnode );
+               $html = $dom->saveHTML();
+
                return $this->add_data( $html );
        }
 

-- 
To view, visit https://gerrit.wikimedia.org/r/297729
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I724a033088e4ee0b0fb203ee0054dfc328b6c2bc
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/DonationInterface
Gerrit-Branch: master
Gerrit-Owner: Cdentinger <cdentin...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to