mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 02:23:58 +00:00
Refactored duplicated code in Util
Change-Id: I05d02b73cd35b4b61843fdc17e97a4a8c5d0e8b6
This commit is contained in:
parent
595dfc0615
commit
de1d734f23
|
@ -104,22 +104,6 @@ var Util = {
|
|||
}
|
||||
},
|
||||
|
||||
lookup: function ( kvs, key ) {
|
||||
if ( ! kvs ) {
|
||||
return null;
|
||||
}
|
||||
var kv;
|
||||
for ( var i = 0, l = kvs.length; i < l; i++ ) {
|
||||
kv = kvs[i];
|
||||
if ( kv.k.trim() === key ) {
|
||||
// found, return it.
|
||||
return kv.v;
|
||||
}
|
||||
}
|
||||
// nothing found!
|
||||
return null;
|
||||
},
|
||||
|
||||
lookupKV: function ( kvs, key ) {
|
||||
if ( ! kvs ) {
|
||||
return null;
|
||||
|
@ -136,6 +120,11 @@ var Util = {
|
|||
return null;
|
||||
},
|
||||
|
||||
lookup: function ( kvs, key ) {
|
||||
var kv = this.lookupKV(kvs, key);
|
||||
return kv == null ? null : kv.v;
|
||||
},
|
||||
|
||||
lookupValue: function ( kvs, key ) {
|
||||
if ( ! kvs ) {
|
||||
return null;
|
||||
|
|
Loading…
Reference in a new issue