Skip to content

Commit 6c0ee19

Browse files
authored
Merge pull request #65 from wmde/addNull
Allow setting Fingerprint terms to null
2 parents 5e1c81b + 6347a7f commit 6c0ee19

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/Fingerprint.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,10 @@ $.extend( SELF.prototype, {
8989

9090
/**
9191
* @param {string} languageCode
92-
* @param {wikibase.datamodel.Term} term
92+
* @param {wikibase.datamodel.Term|null} term
9393
*/
9494
setLabel: function( languageCode, term ) {
95-
if ( term.getText() === '' ) {
95+
if ( term === null || term.getText() === '' ) {
9696
this._labels.removeItemByKey( languageCode );
9797
} else {
9898
this._labels.setItem( languageCode, term );
@@ -148,10 +148,10 @@ $.extend( SELF.prototype, {
148148

149149
/**
150150
* @param {string} languageCode
151-
* @param {wikibase.datamodel.Term} term
151+
* @param {wikibase.datamodel.Term|null} term
152152
*/
153153
setDescription: function( languageCode, term ) {
154-
if ( term.getText() === '' ) {
154+
if ( term === null || term.getText() === '' ) {
155155
this._descriptions.removeItemByKey( languageCode );
156156
} else {
157157
this._descriptions.setItem( languageCode, term );
@@ -207,7 +207,7 @@ $.extend( SELF.prototype, {
207207

208208
/**
209209
* @param {string|wikibase.datamodel.MultiTermMap} languageCodeOrAliases
210-
* @param {wikibase.datamodel.MultiTerm} [aliases]
210+
* @param {wikibase.datamodel.MultiTerm|null} [aliases]
211211
*
212212
* @throws {Error} when passing a MultiTerm without a language code.
213213
* @throws {Error} when passing a MultiTermMap with a language code.
@@ -222,12 +222,12 @@ $.extend( SELF.prototype, {
222222
aliases = languageCodeOrAliases;
223223
}
224224

225-
if( aliases instanceof wb.datamodel.MultiTerm ) {
225+
if( aliases === null || aliases instanceof wb.datamodel.MultiTerm ) {
226226
if( !languageCode ) {
227227
throw new Error( 'Language code the wb.datamodel.MultiTerm object should be set '
228228
+ 'for needs to be specified' );
229229
}
230-
if ( aliases.isEmpty() ) {
230+
if ( aliases === null || aliases.isEmpty() ) {
231231
this._aliases.removeItemByKey( languageCode );
232232
} else {
233233
this._aliases.setItem( languageCode, aliases );

0 commit comments

Comments
 (0)