Bartosz Dziewoński has uploaded a new change for review.
https://gerrit.wikimedia.org/r/230568
Change subject: Make the demo compatible with IE 8
......................................................................
Make the demo compatible with IE 8
* Insert <link> elements into DOM before setting 'href', as otherwise
the stylesheets are not loaded.
* Only pass real Arrays to Function#apply, not array-like objects, to
avoid exceptions.
Change-Id: Idd5c829ac1d0786d9e64637771ea7a0a5fc9cfe1
---
M demos/demo.js
1 file changed, 8 insertions(+), 6 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/oojs/ui refs/changes/68/230568/1
diff --git a/demos/demo.js b/demos/demo.js
index 04203cd..6883b68 100644
--- a/demos/demo.js
+++ b/demos/demo.js
@@ -12,7 +12,6 @@
this.normalizeHash();
// Properties
- this.stylesheetLinks = this.getStylesheetLinks();
this.mode = this.getCurrentMode();
this.$menu = $( '<div>' );
this.pageDropdown = new OO.ui.DropdownWidget( {
@@ -77,7 +76,7 @@
$( 'body' ).addClass( 'oo-ui-' + this.mode.direction );
// Correctly apply direction to the <html> tags as well
$( 'html' ).attr( 'dir', this.mode.direction );
- $( 'head' ).append( this.stylesheetLinks );
+ this.stylesheetLinks = this.addStylesheetLinks( $( 'head' ) );
OO.ui.theme = new ( this.constructor.static.themes[ this.mode.theme
].theme )();
};
@@ -219,8 +218,8 @@
*/
OO.ui.Demo.prototype.initialize = function () {
var demo = this,
- promises = $( this.stylesheetLinks ).map( function () {
- return $( this ).data( 'load-promise' );
+ promises = this.stylesheetLinks.map( function ( el ) {
+ return $( el ).data( 'load-promise' );
} );
$.when.apply( $, promises )
.done( function () {
@@ -321,11 +320,12 @@
};
/**
- * Get link elements for the current mode.
+ * Get and insert link elements for the current mode.
*
+ * @param {jQuery} $where Node to insert the links into
* @return {HTMLElement[]} List of link elements
*/
-OO.ui.Demo.prototype.getStylesheetLinks = function () {
+OO.ui.Demo.prototype.addStylesheetLinks = function ( $where ) {
var i, len, links, fragments,
factors = this.getFactors(),
theme = this.getCurrentFactorValues()[ 1 ],
@@ -357,6 +357,8 @@
load: deferred.resolve,
error: deferred.reject
} );
+ // Insert into DOM before setting 'href' for IE 8 compatibility
+ $where.append( $link );
link.rel = 'stylesheet';
link.href = url;
return link;
--
To view, visit https://gerrit.wikimedia.org/r/230568
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Idd5c829ac1d0786d9e64637771ea7a0a5fc9cfe1
Gerrit-PatchSet: 1
Gerrit-Project: oojs/ui
Gerrit-Branch: master
Gerrit-Owner: Bartosz Dziewoński <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits