mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-01-27 09:24:45 +00:00
Got rid of some potentially dodgy hasOwnProperty() calls
This commit is contained in:
parent
557a7b0eba
commit
d99b70e0b2
@ -68,7 +68,7 @@ Dependencies.prototype.hasChanged = function(changes,contextTiddlerTitle) {
|
||||
return true;
|
||||
}
|
||||
for(var c in changes) {
|
||||
if(this.tiddlers.hasOwnProperty(c)) {
|
||||
if($tw.utils.hop(this.tiddlers,c)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -151,7 +151,7 @@ exports.executeMacro = function() {
|
||||
exports.refreshInDom = function(changes) {
|
||||
var needChildrenRefresh = true; // Avoid refreshing the children nodes if we don't need to
|
||||
// If the state tiddler has changed then reset the open state
|
||||
if(this.hasParameter("state") && changes.hasOwnProperty(this.params.state)) {
|
||||
if(this.hasParameter("state") && $tw.utils.hop(changes,this.params.state)) {
|
||||
this.isOpen = this.getOpenState();
|
||||
}
|
||||
// Render the children if the slider is open and we don't have any children yet
|
||||
|
@ -39,7 +39,7 @@ exports.handleEvent = function(event) {
|
||||
template = this.hasParameter("defaultViewTemplate") ? this.params.defaultViewTemplate : "ViewTemplate";
|
||||
storyTiddler = this.wiki.getTiddler(this.params.story);
|
||||
story = {tiddlers: []};
|
||||
if(storyTiddler && storyTiddler.fields.hasOwnProperty("text")) {
|
||||
if(storyTiddler && $tw.utils.hop(storyTiddler.fields,"text")) {
|
||||
story = JSON.parse(storyTiddler.fields.text);
|
||||
}
|
||||
story.tiddlers.unshift({title: event.navigateTo, template: template});
|
||||
@ -52,7 +52,7 @@ exports.handleEvent = function(event) {
|
||||
template = this.hasParameter("defaultEditTemplate") ? this.params.defaultEditTemplate : "EditTemplate";
|
||||
storyTiddler = this.wiki.getTiddler(this.params.story);
|
||||
story = {tiddlers: []};
|
||||
if(storyTiddler && storyTiddler.fields.hasOwnProperty("text")) {
|
||||
if(storyTiddler && $tw.utils.hop(storyTiddler.fields,"text")) {
|
||||
story = JSON.parse(storyTiddler.fields.text);
|
||||
}
|
||||
for(t=0; t<story.tiddlers.length; t++) {
|
||||
@ -81,14 +81,14 @@ exports.handleEvent = function(event) {
|
||||
storyTiddler = this.wiki.getTiddler(this.params.story);
|
||||
story = {tiddlers: []};
|
||||
storyTiddlerModified = false;
|
||||
if(storyTiddler && storyTiddler.fields.hasOwnProperty("text")) {
|
||||
if(storyTiddler && $tw.utils.hop(storyTiddler.fields,"text")) {
|
||||
story = JSON.parse(storyTiddler.fields.text);
|
||||
}
|
||||
for(t=0; t<story.tiddlers.length; t++) {
|
||||
storyRecord = story.tiddlers[t];
|
||||
if(storyRecord.title === event.tiddlerTitle && storyRecord.template !== template) {
|
||||
tiddler = this.wiki.getTiddler(storyRecord.title);
|
||||
if(tiddler && tiddler.fields.hasOwnProperty("draft.title")) {
|
||||
if(tiddler && $tw.utils.hop(tiddler.fields,"draft.title")) {
|
||||
// Save the draft tiddler as the real tiddler
|
||||
this.wiki.addTiddler(new $tw.Tiddler(tiddler,{title: tiddler.fields["draft.title"],"draft.title": undefined, "draft.of": undefined}));
|
||||
// Remove the draft tiddler
|
||||
|
@ -117,7 +117,7 @@ Macro.prototype.parseMacroParamString = function(paramString) {
|
||||
};
|
||||
|
||||
Macro.prototype.hasParameter = function(name) {
|
||||
return this.params.hasOwnProperty(name);
|
||||
return $tw.utils.hop(this.params,name);
|
||||
};
|
||||
|
||||
Macro.prototype.cloneContent = function() {
|
||||
|
@ -75,7 +75,7 @@ var ArgParser = function(argString,options) {
|
||||
}
|
||||
if(n.evaluated === true) {
|
||||
n = "{{" + n.string + "}}";
|
||||
} else if (typeof n === "object" && n.hasOwnProperty("string")) {
|
||||
} else if (typeof n === "object" && $tw.utils.hop(n,"string")) {
|
||||
n = n.string;
|
||||
}
|
||||
this.byPos.push({n:n, v:v});
|
||||
@ -90,7 +90,7 @@ var ArgParser = function(argString,options) {
|
||||
for(var t=0; t<this.byPos.length; t++) {
|
||||
n = this.byPos[t].n;
|
||||
v = this.byPos[t].v;
|
||||
if(this.byName.hasOwnProperty(n))
|
||||
if($tw.utils.hop(this.byName,n))
|
||||
this.byName[n].push(v);
|
||||
else
|
||||
this.byName[n] = [v];
|
||||
|
@ -62,7 +62,7 @@ exports.touchTiddler = function(title,isDeleted) {
|
||||
this.changedTiddlers[title][isDeleted ? "deleted" : "modified"] = true;
|
||||
// Increment the change count
|
||||
this.changeCount = this.changeCount || {};
|
||||
if(this.changeCount.hasOwnProperty(title)) {
|
||||
if($tw.utils.hop(this.changeCount,title)) {
|
||||
this.changeCount[title]++;
|
||||
} else {
|
||||
this.changeCount[title] = 1;
|
||||
@ -86,7 +86,7 @@ exports.touchTiddler = function(title,isDeleted) {
|
||||
|
||||
exports.getChangeCount = function(title) {
|
||||
this.changeCount = this.changeCount || {};
|
||||
if(this.changeCount.hasOwnProperty(title)) {
|
||||
if($tw.utils.hop(this.changeCount,title)) {
|
||||
return this.changeCount[title];
|
||||
} else {
|
||||
return 0;
|
||||
@ -227,7 +227,7 @@ exports.getCacheForTiddler = function(title,cacheName,initializer) {
|
||||
// Clear all caches associated with a particular tiddler
|
||||
exports.clearCache = function(title) {
|
||||
this.caches = this.caches || {};
|
||||
if(this.caches.hasOwnProperty(title)) {
|
||||
if($tw.utils.hop(this.caches,title)) {
|
||||
delete this.caches[title];
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user