mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-09-27 04:06:51 +00:00
Make LinkCache fail more gracefully when given undefined
If you tried to do styleElement( undefined, $element ), you'd get an exception in the mw.Title constructor from a setTimeout. That's not very nice, and there's no point sending non-strings through the queue and other data structures in LinkCache, so instead just make get() return a rejected promise when given non-string values. Change-Id: Iab06929d7e232a8ecd8eb1eff9d1190c303421c1
This commit is contained in:
parent
6c4c3408b8
commit
2ed648c4db
|
@ -62,6 +62,12 @@
|
|||
* @returns {jQuery.Promise} Promise that will be resolved with the data once it's available
|
||||
*/
|
||||
ve.init.mw.LinkCache.prototype.get = function ( name ) {
|
||||
if ( typeof name !== 'string' ) {
|
||||
// Don't bother letting things like undefined or null make it all the way through,
|
||||
// just reject them here. Otherwise they'll cause problems or exceptions at random
|
||||
// other points in this file.
|
||||
return $.Deferred().reject().promise();
|
||||
}
|
||||
if ( !hasOwn.call( this.cache, name ) ) {
|
||||
this.cache[name] = $.Deferred();
|
||||
this.queue.push( name );
|
||||
|
|
Loading…
Reference in a new issue