Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix error if dictionay use 'hasOwnProperty' keyword #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions difflib.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ DAMAGE.
***/
/* Author: Chas Emerick <[email protected]> */
var __whitespace = {" ":true, "\t":true, "\n":true, "\f":true, "\r":true};

function __hasOwnProperty(obj, target){
return Object.prototype.hasOwnProperty.call(obj, target);
}
var difflib = {
defaultJunkFunction: function (c) {
return __whitespace.hasOwnProperty(c);
Expand Down Expand Up @@ -88,7 +90,7 @@ var difflib = {
// is in the dict (js object) provided to this function; replaces being able to
// carry around dict.has_key in python...
__isindict: function (dict) {
return function (key) { return dict.hasOwnProperty(key); };
return function (key) { return __hasOwnProperty(dict, key); };
},

// replacement for python's dict.get function -- need easy default values
Expand Down Expand Up @@ -122,7 +124,7 @@ var difflib = {
var populardict = {};
for (var i = 0; i < b.length; i++) {
var elt = b[i];
if (b2j.hasOwnProperty(elt)) {
if (__hasOwnProperty(b2j, elt)) {
var indices = b2j[elt];
if (n >= 200 && indices.length * 100 > n) {
populardict[elt] = 1;
Expand All @@ -145,7 +147,7 @@ var difflib = {
var junkdict = {};
if (isjunk) {
for (var elt in populardict) {
if (populardict.hasOwnProperty(elt) && isjunk(elt)) {
if (__hasOwnProperty(populardict, elt) && isjunk(elt)) {
junkdict[elt] = 1;
delete populardict[elt];
}
Expand Down