jenkins-bot has submitted this change and it was merged.

Change subject: Simplified iframe initialization
......................................................................


Simplified iframe initialization

Rather than attach a function to the window and trigger it from a script
tag in the document body, it's much simpler to just use the references
we already have to execute the code immediately and directly.

This also fixes issues in Firefox where reaching in and adding functions
to the window wasn't allowed.

Change-Id: If7a84edf6ae4549b19ce36a3477311c46dbadea7
---
M modules/ve/ui/ve.ui.Frame.js
1 file changed, 22 insertions(+), 25 deletions(-)

Approvals:
  Robmoen: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/modules/ve/ui/ve.ui.Frame.js b/modules/ve/ui/ve.ui.Frame.js
index eabf9b9..ae1f806 100644
--- a/modules/ve/ui/ve.ui.Frame.js
+++ b/modules/ve/ui/ve.ui.Frame.js
@@ -68,45 +68,42 @@
  * @emits initialize
  */
 ve.ui.Frame.prototype.onLoad = function () {
-       var win = this.$.prop( 'contentWindow' ),
+       var interval, rules,
+               win = this.$.prop( 'contentWindow' ),
                doc = win.document,
-               stylesheets = this.config.stylesheets,
+               style = doc.createElement( 'style' ),
                initialize = ve.bind( function () {
                        this.initialized = true;
                        this.emit( 'initialize' );
                }, this );
 
        // Initialize contents
-       win.setup = function () {
-               var interval, rules,
-                       style = doc.createElement( 'style' );
-
-               // Import all stylesheets
-               style.textContent = '@import "' + stylesheets.join( 
'";\n@import "' ) + '";';
-               doc.body.appendChild( style );
-
-               // Poll for access to stylesheet content
-               interval = setInterval( function () {
-                       try {
-                               // MAGIC: only accessible when the stylesheet 
is loaded
-                               rules = style.sheet.cssRules;
-                               // If that didn't throw an exception, we're 
done loading
-                               clearInterval( interval );
-                               // Protect against IE running interval one 
extra time after clearing
-                               if ( !this.initialized ) {
-                                       initialize();
-                               }
-                       } catch ( e ) {}
-               } );
-       };
        doc.open();
        doc.write(
                '<body style="padding:0;margin:0;">' +
-                       '<div 
class="ve-ui-frame-content"></div><script>setup();</script>' +
+                       '<div class="ve-ui-frame-content"></div>' +
                '</body>'
        );
        doc.close();
 
+       // Import all stylesheets
+       style.textContent = '@import "' + this.config.stylesheets.join( 
'";\n@import "' ) + '";';
+       doc.body.appendChild( style );
+
+       // Poll for access to stylesheet content
+       interval = setInterval( ve.bind( function () {
+               try {
+                       // MAGIC: only accessible when the stylesheet is loaded
+                       rules = style.sheet.cssRules;
+                       // If that didn't throw an exception, we're done loading
+                       clearInterval( interval );
+                       // Protect against IE running interval one extra time 
after clearing
+                       if ( !this.initialized ) {
+                               initialize();
+                       }
+               } catch ( e ) { }
+       }, this ), 10 );
+
        // Properties
        this.$$ = ve.ui.get$$( doc, this );
        this.$content = this.$$( '.ve-ui-frame-content' );

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

Gerrit-MessageType: merged
Gerrit-Change-Id: If7a84edf6ae4549b19ce36a3477311c46dbadea7
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Trevor Parscal <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>
Gerrit-Reviewer: Robmoen <[email protected]>
Gerrit-Reviewer: Trevor Parscal <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to