Skip to content

Commit

Permalink
Fix #213: Throw away this.isArray()
Browse files Browse the repository at this point in the history
  • Loading branch information
miripiruni committed Jun 30, 2016
1 parent 26d0725 commit caad627
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 64 deletions.
2 changes: 1 addition & 1 deletion lib/bemhtml/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ BEMHTML.prototype.renderMix = function renderMix(entity,
visited[entity.jsClass] = true;

// Transform mix to the single-item array if it's not array
if (!utils.isArray(mix))
if (!Array.isArray(mix))
mix = [ mix ];

var classBuilder = this.classBuilder;
Expand Down
1 change: 0 additions & 1 deletion lib/bemxjst/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ function Context(bemxjst) {
exports.Context = Context;

Context.prototype._flush = null;
Context.prototype.isArray = utils.isArray;

Context.prototype.isSimple = utils.isSimple;

Expand Down
2 changes: 1 addition & 1 deletion lib/bemxjst/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ BEMXJST.prototype._run = function _run(context) {
var res;
if (context === undefined || context === '' || context === null)
res = this.runEmpty();
else if (utils.isArray(context))
else if (Array.isArray(context))
res = this.runMany(context);
else if (
context.html &&
Expand Down
3 changes: 1 addition & 2 deletions lib/bemxjst/match.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
var utils = require('./utils');
var tree = require('./tree');
var PropertyMatch = tree.PropertyMatch;
var OnceMatch = tree.OnceMatch;
Expand Down Expand Up @@ -83,7 +82,7 @@ function MatchTemplate(mode, template) {
for (var i = 0, j = 0; i < this.predicates.length; i++, j++) {
var pred = template.predicates[i];
if (pred instanceof PropertyMatch) {
if (utils.isArray(pred.key))
if (Array.isArray(pred.key))
this.predicates[j] = new MatchNested(this, pred);
else
this.predicates[j] = new MatchProperty(this, pred);
Expand Down
9 changes: 0 additions & 9 deletions lib/bemxjst/utils.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
var toString = Object.prototype.toString;

exports.isArray = Array.isArray;
if (!exports.isArray) {
exports.isArray = function isArrayPolyfill(obj) {
return toString.call(obj) === '[object Array]';
};
}

exports.xmlEscape = function(str) {
return (str + '')
.replace(/&/g, '&amp;')
Expand Down
50 changes: 0 additions & 50 deletions test/bemcontext-isarray-test.js

This file was deleted.

0 comments on commit caad627

Please sign in to comment.