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(core): Don’t redefine clone variable #1778

Merged
merged 3 commits into from
Mar 1, 2019
Merged
Show file tree
Hide file tree
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
15 changes: 8 additions & 7 deletions components/prism-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,16 @@ var _ = _self.Prism = {

// Deep clone a language definition (e.g. to extend it)
clone: function deepClone(o, visited) {
var type = _.util.type(o);
var clone, id, type = _.util.type(o);
visited = visited || {};

switch (type) {
case 'Object':
var id = _.util.objId(o);
id = _.util.objId(o);
if (visited[id]) {
return visited[id];
}
var clone = {};
clone = {};
visited[id] = clone;

for (var key in o) {
Expand All @@ -66,21 +66,22 @@ var _ = _self.Prism = {
return clone;

case 'Array':
var id = _.util.objId(o);
id = _.util.objId(o);
if (visited[id]) {
return visited[id];
}
var clone = [];
clone = [];
visited[id] = clone;

o.forEach(function (v, i) {
clone[i] = deepClone(v, visited);
});

return clone;
}

return o;
default:
return o;
}
}
},

Expand Down
2 changes: 1 addition & 1 deletion components/prism-core.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 8 additions & 7 deletions prism.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,16 @@ var _ = _self.Prism = {

// Deep clone a language definition (e.g. to extend it)
clone: function deepClone(o, visited) {
var type = _.util.type(o);
var clone, id, type = _.util.type(o);
visited = visited || {};

switch (type) {
case 'Object':
var id = _.util.objId(o);
id = _.util.objId(o);
if (visited[id]) {
return visited[id];
}
var clone = {};
clone = {};
visited[id] = clone;

for (var key in o) {
Expand All @@ -71,21 +71,22 @@ var _ = _self.Prism = {
return clone;

case 'Array':
var id = _.util.objId(o);
id = _.util.objId(o);
if (visited[id]) {
return visited[id];
}
var clone = [];
clone = [];
visited[id] = clone;

o.forEach(function (v, i) {
clone[i] = deepClone(v, visited);
});

return clone;
}

return o;
default:
return o;
}
}
},

Expand Down