mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-25 19:17:19 +00:00
Fix jsonset crash when applied to primitive types
See https://talk.tiddlywiki.org/t/final-checks-before-release-of-v5-3-2/8560/7
This commit is contained in:
parent
622512c380
commit
c282208668
@ -273,7 +273,10 @@ function setDataItem(data,indexes,value) {
|
|||||||
lastIndex = $tw.utils.parseInt(lastIndex);
|
lastIndex = $tw.utils.parseInt(lastIndex);
|
||||||
if(lastIndex < 0) { lastIndex = lastIndex + current.length };
|
if(lastIndex < 0) { lastIndex = lastIndex + current.length };
|
||||||
}
|
}
|
||||||
current[lastIndex] = value;
|
// Only set indexes on objects and arrays
|
||||||
|
if(typeof current === "object") {
|
||||||
|
current[lastIndex] = value;
|
||||||
|
}
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,6 +124,7 @@ describe("json filter tests", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should support the jsonset operator", function() {
|
it("should support the jsonset operator", function() {
|
||||||
|
expect(wiki.filterTiddlers("[jsonset[a],[aa]]")).toEqual(['"First"','"Second"','"Third"']);
|
||||||
expect(wiki.filterTiddlers("[{First}jsonset[]]")).toEqual(['{"a":"one","b":"","c":1.618,"d":{"e":"four","f":["five","six",true,false,null]}}']);
|
expect(wiki.filterTiddlers("[{First}jsonset[]]")).toEqual(['{"a":"one","b":"","c":1.618,"d":{"e":"four","f":["five","six",true,false,null]}}']);
|
||||||
expect(wiki.filterTiddlers("[{First}jsonset[],[Antelope]]")).toEqual(['"Antelope"']);
|
expect(wiki.filterTiddlers("[{First}jsonset[],[Antelope]]")).toEqual(['"Antelope"']);
|
||||||
expect(wiki.filterTiddlers("[{First}jsonset:number[],[not a number]]")).toEqual(['0']);
|
expect(wiki.filterTiddlers("[{First}jsonset:number[],[not a number]]")).toEqual(['0']);
|
||||||
|
Loading…
Reference in New Issue
Block a user