jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/403893 )
Change subject: Widgets: Allow titles with name of Object.prototypes
......................................................................
Widgets: Allow titles with name of Object.prototypes
Bug: T184776
Change-Id: I1ba75e779e9c4f0ce5957d752a02da27044b9d07
---
M resources/src/mediawiki.widgets/mw.widgets.CategoryCapsuleItemWidget.js
M resources/src/mediawiki.widgets/mw.widgets.CategoryMultiselectWidget.js
M resources/src/mediawiki.widgets/mw.widgets.TitleWidget.js
3 files changed, 14 insertions(+), 10 deletions(-)
Approvals:
Bartosz Dziewoński: Looks good to me, approved
jenkins-bot: Verified
diff --git
a/resources/src/mediawiki.widgets/mw.widgets.CategoryCapsuleItemWidget.js
b/resources/src/mediawiki.widgets/mw.widgets.CategoryCapsuleItemWidget.js
index 42ef1ac..17da7d8 100644
--- a/resources/src/mediawiki.widgets/mw.widgets.CategoryCapsuleItemWidget.js
+++ b/resources/src/mediawiki.widgets/mw.widgets.CategoryCapsuleItemWidget.js
@@ -6,6 +6,8 @@
*/
( function ( $, mw ) {
+ var hasOwn = Object.prototype.hasOwnProperty;
+
/**
* @class mw.widgets.PageExistenceCache
* @private
@@ -38,10 +40,10 @@
queue = this.existenceCheckQueue;
this.existenceCheckQueue = {};
titles = Object.keys( queue ).filter( function ( title ) {
- if ( cache.existenceCache.hasOwnProperty( title ) ) {
+ if ( hasOwn.call( cache.existenceCache, title ) ) {
queue[ title ].resolve( cache.existenceCache[
title ] );
}
- return !cache.existenceCache.hasOwnProperty( title );
+ return !hasOwn.call( cache.existenceCache, title );
} );
if ( !titles.length ) {
return;
@@ -63,7 +65,7 @@
} );
titles.forEach( function ( title ) {
var normalizedTitle = title;
- while ( normalized[ normalizedTitle ] ) {
+ while ( hasOwn.call( normalized,
normalizedTitle ) ) {
normalizedTitle = normalized[
normalizedTitle ];
}
cache.existenceCache[ title ] = pages[
normalizedTitle ];
@@ -81,7 +83,7 @@
*/
PageExistenceCache.prototype.checkPageExistence = function ( title ) {
var key = title.getPrefixedText();
- if ( !this.existenceCheckQueue[ key ] ) {
+ if ( !hasOwn.call( this.existenceCheckQueue, key ) ) {
this.existenceCheckQueue[ key ] = $.Deferred();
}
this.processExistenceCheckQueueDebounced();
diff --git
a/resources/src/mediawiki.widgets/mw.widgets.CategoryMultiselectWidget.js
b/resources/src/mediawiki.widgets/mw.widgets.CategoryMultiselectWidget.js
index d14a47a..045744c 100644
--- a/resources/src/mediawiki.widgets/mw.widgets.CategoryMultiselectWidget.js
+++ b/resources/src/mediawiki.widgets/mw.widgets.CategoryMultiselectWidget.js
@@ -5,7 +5,8 @@
* @license The MIT License (MIT); see LICENSE.txt
*/
( function ( $, mw ) {
- var NS_CATEGORY = mw.config.get( 'wgNamespaceIds' ).category;
+ var hasOwn = Object.prototype.hasOwnProperty,
+ NS_CATEGORY = mw.config.get( 'wgNamespaceIds' ).category;
/**
* Category selector widget. Displays an OO.ui.CapsuleMultiselectWidget
@@ -273,7 +274,7 @@
cacheKey = input + searchType.toString();
// Check cache
- if ( this.searchCache[ cacheKey ] !== undefined ) {
+ if ( hasOwn.call( this.searchCache, cacheKey ) ) {
return this.searchCache[ cacheKey ];
}
diff --git a/resources/src/mediawiki.widgets/mw.widgets.TitleWidget.js
b/resources/src/mediawiki.widgets/mw.widgets.TitleWidget.js
index 0c6385b..190962c 100644
--- a/resources/src/mediawiki.widgets/mw.widgets.TitleWidget.js
+++ b/resources/src/mediawiki.widgets/mw.widgets.TitleWidget.js
@@ -5,6 +5,7 @@
* @license The MIT License (MIT); see LICENSE.txt
*/
( function ( $, mw ) {
+ var hasOwn = Object.prototype.hasOwnProperty;
/**
* Mixin for title widgets
@@ -254,7 +255,7 @@
titles.push( suggestionPage.title );
}
- redirects = redirectsTo[ suggestionPage.title ] || [];
+ redirects = hasOwn.call( redirectsTo,
suggestionPage.title ) ? redirectsTo[ suggestionPage.title ] : [];
for ( i = 0, len = redirects.length; i < len; i++ ) {
pageData[ redirects[ i ] ] = {
missing: false,
@@ -278,7 +279,7 @@
// mismatch where normalisation would make them matching
(T50476)
pageExistsExact = (
- Object.prototype.hasOwnProperty.call( pageData,
this.getQueryValue() ) &&
+ hasOwn.call( pageData, this.getQueryValue() ) &&
(
!pageData[ this.getQueryValue() ].missing ||
pageData[ this.getQueryValue() ].known
@@ -286,7 +287,7 @@
);
pageExists = pageExistsExact || (
titleObj &&
- Object.prototype.hasOwnProperty.call( pageData,
titleObj.getPrefixedText() ) &&
+ hasOwn.call( pageData, titleObj.getPrefixedText() ) &&
(
!pageData[ titleObj.getPrefixedText() ].missing
||
pageData[ titleObj.getPrefixedText() ].known
@@ -303,7 +304,7 @@
}
for ( i = 0, len = titles.length; i < len; i++ ) {
- page = pageData[ titles[ i ] ] || {};
+ page = hasOwn.call( pageData, titles[ i ] ) ? pageData[
titles[ i ] ] : {};
items.push( this.createOptionWidget(
this.getOptionWidgetData( titles[ i ], page ) ) );
}
--
To view, visit https://gerrit.wikimedia.org/r/403893
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I1ba75e779e9c4f0ce5957d752a02da27044b9d07
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Fomafix <[email protected]>
Gerrit-Reviewer: Bartosz Dziewoński <[email protected]>
Gerrit-Reviewer: Jforrester <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits