Merge pull request #14044 from calixteman/bug1719148
Annotations - Avoid empty value in text field when storage contains something for it (bug 1719148)
This commit is contained in:
commit
20eb6ca2ec
@ -42,7 +42,12 @@ class AnnotationStorage {
|
|||||||
* @returns {Object}
|
* @returns {Object}
|
||||||
*/
|
*/
|
||||||
getValue(key, defaultValue) {
|
getValue(key, defaultValue) {
|
||||||
return this._storage.get(key) ?? defaultValue;
|
const value = this._storage.get(key);
|
||||||
|
if (value === undefined) {
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Object.assign(defaultValue, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -35,6 +35,24 @@ describe("AnnotationStorage", function () {
|
|||||||
}).value;
|
}).value;
|
||||||
expect(value).toEqual("hello world");
|
expect(value).toEqual("hello world");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should get set values and default ones in the annotation storage", function () {
|
||||||
|
const annotationStorage = new AnnotationStorage();
|
||||||
|
annotationStorage.setValue("123A", {
|
||||||
|
value: "hello world",
|
||||||
|
hello: "world",
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = annotationStorage.getValue("123A", {
|
||||||
|
value: "an other string",
|
||||||
|
world: "hello",
|
||||||
|
});
|
||||||
|
expect(result).toEqual({
|
||||||
|
value: "hello world",
|
||||||
|
hello: "world",
|
||||||
|
world: "hello",
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("SetValue", function () {
|
describe("SetValue", function () {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user