build: Replace jscs+jshint with eslint
[lhc/web/wiklou.git] / resources / src / mediawiki / api / parse.js
index 02528dc..f38e88b 100644 (file)
                 * @return {string} return.done.data Parsed HTML of `wikitext`.
                 */
                parse: function ( content, additionalParams ) {
-                       var apiPromise, config = $.extend( {
-                               formatversion: 2,
-                               action: 'parse',
-                               contentmodel: 'wikitext'
-                       }, additionalParams );
+                       var apiPromise,
+                               config = $.extend( {
+                                       formatversion: 2,
+                                       action: 'parse',
+                                       contentmodel: 'wikitext'
+                               }, additionalParams );
 
-                       if ( typeof content === 'string' ) {
-                               // Wikitext
-                               config.text = content;
-                       } else {
-                               // mw.Title
+                       if ( mw.Title && content instanceof mw.Title ) {
+                               // Parse existing page
                                config.page = content.getPrefixedDb();
+                       } else {
+                               // Parse wikitext from input
+                               config.text = String( content );
                        }
 
                        apiPromise = this.get( config );