r60985 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r60984‎ | r60985 | r60986 >
Date:20:52, 12 January 2010
Author:dale
Status:deferred
Tags:
Comment:
* hot-fix for cross domain style sheet ( style sheets now come from bits.wikimedia.org )
Modified paths:
  • /branches/js2-work/phase3/js/mwEmbed/mwEmbed.js (modified) (history)

Diff [purge]

Index: branches/js2-work/phase3/js/mwEmbed/mwEmbed.js
@@ -1643,8 +1643,7 @@
16441644 *
16451645 * @param {Function} callback Function to run once DOM and jQuery are ready
16461646 */
1647 - mw.ready = function( callback ){
1648 - mw.log('addOnloadHook:: ' );
 1647+ mw.ready = function( callback ){
16491648 if( mwReadyFlag === false ){
16501649
16511650 // Add the callbcak to the onLoad function stack
@@ -1653,7 +1652,7 @@
16541653 // Set the mwSetup flag. So that onLoad functions can
16551654 // be called once mwEmbed interfaces are setup.
16561655 if( !mwDomReadyFlag ){
1657 - mw.log( 'set config flag' );
 1656+ //mw.log( 'set config flag' );
16581657 mw.setConfig( 'runSetupMwEmbed', true );
16591658 }else{
16601659 mw.log( 'run setup directly' );
@@ -2262,6 +2261,8 @@
22632262 * On a page with lots of rules it can take some time
22642263 * so avoid calling this function where possible and
22652264 * cache its result
 2265+ *
 2266+ * Note this only works when mwEmbed is on the same domain as the style sheets
22662267 *
22672268 * @param {String} styleRule Style rule name to check
22682269 * @return
@@ -2270,18 +2271,22 @@
22712272 * @type {Boolean}
22722273 */
22732274 mw.styleRuleExists = function ( styleRule ){
2274 - // Set up the skin paths configuration
 2275+ // Set up the skin paths configuration
22752276 for( var i=0 ; i < document.styleSheets.length ; i++ ){
22762277 var rules = null;
2277 - if (document.styleSheets[i].cssRules)
2278 - rules = document.styleSheets[i].cssRules
2279 - else if (document.styleSheets[0].rules)
2280 - rules = document.styleSheets[i].rules
2281 - for(var j=0 ; j < rules.length ; j++ ){
2282 - var rule = rules[j].selectorText;
2283 - if( rule && rule.indexOf( styleRule ) != -1 ){
2284 - return true;
2285 - }
 2278+ try {
 2279+ if ( document.styleSheets[i].cssRules )
 2280+ rules = document.styleSheets[i].cssRules
 2281+ else if (document.styleSheets[0].rules)
 2282+ rules = document.styleSheets[i].rules
 2283+ for(var j=0 ; j < rules.length ; j++ ){
 2284+ var rule = rules[j].selectorText;
 2285+ if( rule && rule.indexOf( styleRule ) != -1 ){
 2286+ return true;
 2287+ }
 2288+ }
 2289+ } catch ( e ){
 2290+ mw.log( 'Error: cross domain style sheet:' + document.styleSheets[i].href);
22862291 }
22872292 }
22882293 return false;

Status & tagging log