diff --git a/.jsduck/categories.json b/.jsduck/categories.json index bfe492bbc7..925e5e194e 100644 --- a/.jsduck/categories.json +++ b/.jsduck/categories.json @@ -68,6 +68,7 @@ "ve.init", "ve.init.Platform", "ve.init.Target", + "window.VisualEditorSupportCheck", "ve.init.sa*" ] }, diff --git a/.jsduck/eg-iframe.html b/.jsduck/eg-iframe.html index 7088d164af..bb5d31801e 100644 --- a/.jsduck/eg-iframe.html +++ b/.jsduck/eg-iframe.html @@ -123,6 +123,9 @@ + + + diff --git a/extension.json b/extension.json index ab99cf3844..93ce9ad6c0 100644 --- a/extension.json +++ b/extension.json @@ -246,6 +246,13 @@ "mobile" ] }, + "ext.visualEditor.supportCheck": { + "scripts": "lib/ve/src/init/ve.init.SupportCheck.js", + "targets": [ + "desktop", + "mobile" + ] + }, "ext.visualEditor.desktopArticleTarget.init": { "class": "VisualEditorDesktopArticleTargetInitModule", "scripts": "modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.init.js", @@ -268,6 +275,7 @@ "mediawiki.util", "mediawiki.api.options", "user.options", + "ext.visualEditor.supportCheck", "ext.visualEditor.track" ], "messages": [ @@ -845,7 +853,8 @@ "rangefix", "papaparse", "jquery.client", - "ext.visualEditor.base" + "ext.visualEditor.base", + "ext.visualEditor.supportCheck" ], "messages": [ "visualeditor", diff --git a/lib/ve b/lib/ve index 33d090bc4e..cdfd84ea54 160000 --- a/lib/ve +++ b/lib/ve @@ -1 +1 @@ -Subproject commit 33d090bc4e15e7936c3ac31956d8f0375c50b709 +Subproject commit cdfd84ea545250dfcc28bdfec011d808cc748951 diff --git a/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.init.js b/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.init.js index 6d2c1ef667..bdd6e38794 100644 --- a/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.init.js +++ b/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.init.js @@ -21,7 +21,7 @@ */ ( function () { var conf, tabMessages, uri, pageExists, viewUri, veEditUri, isViewPage, isEditPage, - pageCanLoadVE, init, support, targetPromise, enable, tempdisable, autodisable, + pageCanLoadVE, init, targetPromise, enable, tempdisable, autodisable, tabPreference, userPrefEnabled, initialWikitext, oldid, multipleSectionEditLinks, active = false, progressStep = 0, @@ -303,36 +303,7 @@ veEditUri.extend( { oldid: oldid } ); } - support = { - es5: !!( - // It would be much easier to do a quick inline function that asserts "use strict" - // works, but since IE9 doesn't support strict mode (and we don't use strict mode) we - // have to instead list all the ES5 features we do use. - Array.isArray && - Array.prototype.filter && - Array.prototype.indexOf && - Array.prototype.map && - Date.now && - Date.prototype.toJSON && - Object.create && - Object.keys && - String.prototype.trim && - window.JSON && - JSON.parse && - JSON.stringify && - Function.prototype.bind - ), - contentEditable: 'contentEditable' in document.createElement( 'div' ), - svg: !!( - document.createElementNS && - document.createElementNS( 'http://www.w3.org/2000/svg', 'svg' ).createSVGRect - ) - }; - init = { - - support: support, - blacklist: conf.blacklist, /** @@ -628,11 +599,6 @@ } }; - support.visualEditor = support.es5 && - support.contentEditable && - support.svg && - ( ( 'vewhitelist' in uri.query ) || !$.client.test( init.blacklist, null, true ) ); - // Cast "0" (T89513) enable = Number( mw.user.options.get( 'visualeditor-enable' ) ); tempdisable = Number( mw.user.options.get( 'visualeditor-betatempdisable' ) ); @@ -656,7 +622,9 @@ // Whether VisualEditor should be available for the current user, page, wiki, mediawiki skin, // browser etc. init.isAvailable = ( - support.visualEditor && + window.VisualEditorSupportCheck() && + + ( ( 'vewhitelist' in uri.query ) || !$.client.test( init.blacklist, null, true ) ) && // Only in supported skins $.inArray( mw.config.get( 'skin' ), conf.skins ) !== -1 &&