summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Dinsmore <queryselector@gmail.com>2013-04-15 20:29:03 -0400
committerNathan Dinsmore <queryselector@gmail.com>2013-04-15 21:06:44 -0400
commit8342c06e274333910fd97a92dd44cecfe8494511 (patch)
tree4189c61cb13c21c50c13acdda6eaf78afbf5a0ae
parent15718f44a30a022a5f45001f3fd2d506da504ff1 (diff)
downloadsnap-8342c06e274333910fd97a92dd44cecfe8494511.tar.gz
snap-8342c06e274333910fd97a92dd44cecfe8494511.zip
Fixed #47
-rw-r--r--blocks.js2
-rw-r--r--gui.js4
-rw-r--r--locale.js10
-rw-r--r--morphic.js16
-rw-r--r--store.js77
-rw-r--r--threads.js10
-rw-r--r--widgets.js2
-rw-r--r--xml.js3
8 files changed, 88 insertions, 36 deletions
diff --git a/blocks.js b/blocks.js
index 061e176..b6ce68a 100644
--- a/blocks.js
+++ b/blocks.js
@@ -5629,7 +5629,7 @@ InputSlotMorph.prototype.dropDownMenu = function () {
}
menu.addItem(' ', null);
for (key in choices) {
- if (choices.hasOwnProperty(key)) {
+ if (Object.prototype.hasOwnProperty.call(choices, key)) {
if (key[0] === '~') {
menu.addLine();
} else {
diff --git a/gui.js b/gui.js
index d4320f2..e0c5659 100644
--- a/gui.js
+++ b/gui.js
@@ -2079,7 +2079,7 @@ IDE_Morph.prototype.aboutSnap = function () {
+ '\nJoe Otto: Morphic Testing and Debugging';
for (module in modules) {
- if (modules.hasOwnProperty(module)) {
+ if (Object.prototype.hasOwnProperty.call(modules, module)) {
versions += ('\n' + module + ' (' +
modules[module] + ')');
}
@@ -3814,7 +3814,7 @@ ProjectDialogMorph.prototype.getLocalProjectList = function () {
var stored, name, dta,
projects = [];
for (stored in localStorage) {
- if (localStorage.hasOwnProperty(stored)
+ if (Object.prototype.hasOwnProperty.call(localStorage, stored)
&& stored.substr(0, 14) === '-snap-project-') {
name = stored.substr(14);
dta = {
diff --git a/locale.js b/locale.js
index 11bbe92..fa71c08 100644
--- a/locale.js
+++ b/locale.js
@@ -61,13 +61,16 @@ function Localizer(language, dict) {
}
Localizer.prototype.translate = function (string) {
- return this.dict[this.language][string] || string;
+ return Object.prototype.hasOwnProperty.call(
+ this.dict[this.language],
+ string
+ ) ? this.dict[this.language][string] || string;
};
Localizer.prototype.languages = function () {
var property, arr = [];
for (property in this.dict) {
- if (this.dict.hasOwnProperty(property)) {
+ if (Object.prototype.hasOwnProperty.call(this.dict, property)) {
arr.push(property);
}
}
@@ -100,7 +103,8 @@ Localizer.prototype.unload = function () {
if (lang !== 'en') {
dict = myself.dict[lang];
for (key in dict) {
- if (dict.hasOwnProperty(key) && !contains(keep, key)) {
+ if (Object.prototype.hasOwnProperty.call(dict, key)
+ && !contains(keep, key)) {
delete dict[key];
}
}
diff --git a/morphic.js b/morphic.js
index 86f6f39..3480cfa 100644
--- a/morphic.js
+++ b/morphic.js
@@ -1114,7 +1114,7 @@ function sizeOf(object) {
// answer the number of own properties
var size = 0, key;
for (key in object) {
- if (object.hasOwnProperty(key)) {
+ if (Object.prototype.hasOwnProperty.call(object, key)) {
size += 1;
}
}
@@ -1251,7 +1251,7 @@ function copy(target) {
target.constructor !== Object) {
c = clone(target.constructor.prototype);
for (property in target) {
- if (target.hasOwnProperty(property)) {
+ if (Object.prototype.hasOwnProperty.call(target, property)) {
c[property] = target[property];
}
}
@@ -6202,7 +6202,10 @@ InspectorMorph.prototype.buildPanes = function () {
[ // format element: [color, predicate(element]
new Color(0, 0, 180),
function (element) {
- return myself.target.hasOwnProperty(element);
+ return Object.prototype.hasOwnProperty.call(
+ myself.target,
+ element
+ );
}
]
]
@@ -9579,7 +9582,10 @@ HandMorph.prototype.processMouseScroll = function (event) {
if (morph) {
morph.mouseScroll(
(event.detail / -3) || (
- event.hasOwnProperty('wheelDeltaY') ?
+ Object.prototype.hasOwnProperty.call(
+ event,
+ 'wheelDeltaY'
+ ) ?
event.wheelDeltaY / 120 :
event.wheelDelta / 120
),
@@ -10499,7 +10505,7 @@ WorldMorph.prototype.about = function () {
var versions = '', module;
for (module in modules) {
- if (modules.hasOwnProperty(module)) {
+ if (Object.prototype.hasOwnProperty.call(modules, module)) {
versions += ('\n' + module + ' (' + modules[module] + ')');
}
}
diff --git a/store.js b/store.js
index bbf2a70..ac88ae4 100644
--- a/store.js
+++ b/store.js
@@ -319,7 +319,8 @@ SnapSerializer.prototype.loadProjectModel = function (xmlNode) {
if (!project.name) {
nameID = 1;
while (
- localStorage.hasOwnProperty(
+ Object.prototype.hasOwnProperty.call(
+ localStorage,
'-snap-project-Untitled ' + nameID
)
) {
@@ -339,7 +340,10 @@ SnapSerializer.prototype.loadProjectModel = function (xmlNode) {
model.stage = model.project.require('stage');
StageMorph.prototype.frameRate = 0;
project.stage = new StageMorph(project.globalVariables);
- if (model.stage.attributes.hasOwnProperty('id')) {
+ if (Object.prototype.hasOwnProperty.call(
+ model.stage.attributes,
+ 'id'
+ )) {
this.objects[model.stage.attributes.id] = project.stage;
}
if (model.stage.attributes.name) {
@@ -399,17 +403,24 @@ SnapSerializer.prototype.loadProjectModel = function (xmlNode) {
var watcher, color, target, hidden, extX, extY;
color = myself.loadColor(model.attributes.color);
- target = model.attributes.hasOwnProperty('scope') ?
- project.sprites[model.attributes.scope] : null;
+ target = Object.prototype.hasOwnProperty.call(
+ model.attributes,
+ 'scope'
+ ) ? project.sprites[model.attributes.scope] : null;
// determine whether the watcher is hidden, slightly
// complicated to retain backward compatibility
// with former tag format: hidden="hidden"
// now it's: hidden="true"
- hidden = model.attributes.hasOwnProperty('hidden')
- && (model.attributes.hidden !== 'false');
+ hidden = Object.prototype.hasOwnProperty.call(
+ model.attributes,
+ 'hidden'
+ ) && (model.attributes.hidden !== 'false');
- if (model.attributes.hasOwnProperty('var')) {
+ if (Object.prototype.hasOwnProperty.call(
+ model.attributes,
+ 'var'
+ )) {
watcher = new WatcherMorph(
model.attributes['var'],
color,
@@ -584,7 +595,10 @@ SnapSerializer.prototype.loadCostumes = function (object, model) {
if (costumes) {
object.costumes = this.loadValue(costumes.require('list'));
}
- if (model.attributes.hasOwnProperty('costume')) {
+ if (Object.prototype.hasOwnProperty.call(
+ model.attributes,
+ 'costume'
+ )) {
costume = object.costumes.asArray()[model.attributes.costume - 1];
if (costume) {
if (costume.loaded) {
@@ -807,7 +821,10 @@ SnapSerializer.prototype.loadBlock = function (model, isReporter) {
// private
var block, info, inputs, isGlobal, rm, receiver;
if (model.tag === 'block') {
- if (model.attributes.hasOwnProperty('var')) {
+ if (Object.prototype.hasOwnProperty.call(
+ model.attributes,
+ 'var'
+ )) {
return SpriteMorph.prototype.variableBlock(
model.attributes['var']
);
@@ -930,19 +947,28 @@ SnapSerializer.prototype.loadValue = function (model) {
myself = this;
function record() {
- if (model.attributes.hasOwnProperty('id')) {
+ if (Object.prototype.hasOwnProperty.call(
+ model.attributes,
+ 'id'
+ )) {
myself.objects[model.attributes.id] = v;
}
- if (model.attributes.hasOwnProperty('mediaID')) {
+ if (Object.prototype.hasOwnProperty.call(
+ model.attributes,
+ 'mediaID'
+ )) {
myself.mediaDict[model.attributes.mediaID] = v;
}
}
switch (model.tag) {
case 'ref':
- if (model.attributes.hasOwnProperty('id')) {
+ if (Object.prototype.hasOwnProperty.call(model.attributes, 'id')) {
return this.objects[model.attributes.id];
}
- if (model.attributes.hasOwnProperty('mediaID')) {
+ if (Object.prototype.hasOwnProperty.call(
+ model.attributes,
+ 'mediaID'
+ )) {
return this.mediaDict[model.attributes.mediaID];
}
throw new Error('expecting a reference id');
@@ -1060,16 +1086,28 @@ SnapSerializer.prototype.loadValue = function (model) {
return v;
case 'costume':
center = new Point();
- if (model.attributes.hasOwnProperty('center-x')) {
+ if (Object.prototype.hasOwnProperty.call(
+ model.attributes,
+ 'center-x'
+ )) {
center.x = parseFloat(model.attributes['center-x']);
}
- if (model.attributes.hasOwnProperty('center-y')) {
+ if (Object.prototype.hasOwnProperty.call(
+ model.attributes,
+ 'center-y'
+ )) {
center.y = parseFloat(model.attributes['center-y']);
}
- if (model.attributes.hasOwnProperty('name')) {
+ if (Object.prototype.hasOwnProperty.call(
+ model.attributes,
+ 'name'
+ )) {
name = model.attributes.name;
}
- if (model.attributes.hasOwnProperty('image')) {
+ if (Object.prototype.hasOwnProperty.call(
+ model.attributes,
+ 'image'
+ )) {
image = new Image();
if (model.attributes.image.indexOf('data:image/svg+xml') === 0
&& !MorphicPreferences.rasterizeSVGs) {
@@ -1108,7 +1146,10 @@ SnapSerializer.prototype.loadValue = function (model) {
audio = new Audio();
audio.src = model.attributes.sound;
v = new Sound(audio, model.attributes.name);
- if (model.attributes.hasOwnProperty('mediaID')) {
+ if (Object.prototype.hasOwnProperty.call(
+ model.attributes,
+ 'mediaID'
+ )) {
myself.mediaDict[model.attributes.mediaID] = v;
}
return v;
diff --git a/threads.js b/threads.js
index 958a270..f5ba28f 100644
--- a/threads.js
+++ b/threads.js
@@ -1821,10 +1821,10 @@ Process.prototype.reportIsIdentical = function (a, b) {
}
function clear() {
- if (a.hasOwnProperty(tag)) {
+ if (Object.prototype.hasOwnProperty.call(a, tag)) {
delete a[tag];
}
- if (b.hasOwnProperty(tag)) {
+ if (Object.prototype.hasOwnProperty.call(b, tag)) {
delete b[tag];
}
}
@@ -2710,7 +2710,7 @@ VariableFrame.prototype.deleteVar = function (name) {
VariableFrame.prototype.names = function () {
var each, names = [];
for (each in this.vars) {
- if (this.vars.hasOwnProperty(each)) {
+ if (Object.prototype.hasOwnProperty.call(this.vars, each)) {
names.push(each);
}
}
@@ -2723,7 +2723,7 @@ VariableFrame.prototype.allNamesDict = function () {
function addKeysToDict(srcDict, trgtDict) {
var eachKey;
for (eachKey in srcDict) {
- if (srcDict.hasOwnProperty(eachKey)) {
+ if (Object.prototype.hasOwnProperty.call(srcDict, eachKey)) {
trgtDict[eachKey] = eachKey;
}
}
@@ -2744,7 +2744,7 @@ VariableFrame.prototype.allNames = function () {
var answer = [], each, dict = this.allNamesDict();
for (each in dict) {
- if (dict.hasOwnProperty(each)) {
+ if (Object.prototype.hasOwnProperty.call(dict, each)) {
answer.push(each);
}
}
diff --git a/widgets.js b/widgets.js
index dbeeefc..cdd775c 100644
--- a/widgets.js
+++ b/widgets.js
@@ -2776,7 +2776,7 @@ InputFieldMorph.prototype.dropDownMenu = function () {
}
menu.addItem(' ', null);
for (key in choices) {
- if (choices.hasOwnProperty(key)) {
+ if (Object.prototype.hasOwnProperty.call(choices, key)) {
if (key[0] === '~') {
menu.addLine();
} else {
diff --git a/xml.js b/xml.js
index 877fff7..88ffd6d 100644
--- a/xml.js
+++ b/xml.js
@@ -246,7 +246,8 @@ XML_Element.prototype.toString = function (isFormatted, indentationLevel) {
// attributes, if any
for (key in this.attributes) {
- if (this.attributes.hasOwnProperty(key) && this.attributes[key]) {
+ if (Object.prototype.hasOwnProperty.call(this.attributes, key)
+ && this.attributes[key]) {
result += ' ' + key + '="' + this.attributes[key] + '"';
}
}