mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-17 22:24:49 +02:00
Add browser-polyfills, remove lodash assign, compact, values
(re: #6087)
This commit is contained in:
@@ -1,24 +1,14 @@
|
||||
describe('iD.Features', function() {
|
||||
describe('iD.rendererFeatures', function() {
|
||||
var dimensions = [1000, 1000];
|
||||
var context, features;
|
||||
|
||||
function _values(obj) {
|
||||
var result = [];
|
||||
for (var k in obj) {
|
||||
if (obj.hasOwnProperty(k)) {
|
||||
result.push(obj[k]);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
beforeEach(function() {
|
||||
context = iD.coreContext();
|
||||
d3.select(document.createElement('div'))
|
||||
.attr('id', 'map')
|
||||
.call(context.map());
|
||||
context.map().zoom(16);
|
||||
features = iD.Features(context);
|
||||
features = iD.rendererFeatures(context);
|
||||
});
|
||||
|
||||
describe('#keys', function() {
|
||||
@@ -74,7 +64,7 @@ describe('iD.Features', function() {
|
||||
iD.osmWay({id: 'boundary', tags: {boundary: 'administrative'}, version: 1}),
|
||||
iD.osmWay({id: 'fence', tags: {barrier: 'fence'}, version: 1})
|
||||
]);
|
||||
var all = _values(graph.base().entities);
|
||||
var all = Object.values(graph.base().entities);
|
||||
var stats;
|
||||
|
||||
features.gatherStats(all, graph, dimensions);
|
||||
@@ -225,7 +215,7 @@ describe('iD.Features', function() {
|
||||
})
|
||||
|
||||
]);
|
||||
var all = _values(graph.base().entities);
|
||||
var all = Object.values(graph.base().entities);
|
||||
|
||||
|
||||
function doMatch(ids) {
|
||||
@@ -463,7 +453,7 @@ describe('iD.Features', function() {
|
||||
var w = iD.osmWay({id: 'w', nodes: [a.id, b.id], tags: {highway: 'path'}, version: 1});
|
||||
var graph = iD.coreGraph([a, b, w]);
|
||||
var geometry = a.geometry(graph);
|
||||
var all = _values(graph.base().entities);
|
||||
var all = Object.values(graph.base().entities);
|
||||
|
||||
features.disable('paths');
|
||||
features.gatherStats(all, graph, dimensions);
|
||||
@@ -491,7 +481,7 @@ describe('iD.Features', function() {
|
||||
version: 1
|
||||
});
|
||||
var graph = iD.coreGraph([outer, inner1, inner2, inner3, r]);
|
||||
var all = _values(graph.base().entities);
|
||||
var all = Object.values(graph.base().entities);
|
||||
|
||||
features.disable('landuse');
|
||||
features.gatherStats(all, graph, dimensions);
|
||||
@@ -508,7 +498,7 @@ describe('iD.Features', function() {
|
||||
var graph = iD.coreGraph([a, b]);
|
||||
var ageo = a.geometry(graph);
|
||||
var bgeo = b.geometry(graph);
|
||||
var all = _values(graph.base().entities);
|
||||
var all = Object.values(graph.base().entities);
|
||||
|
||||
features.disable('points');
|
||||
features.gatherStats(all, graph, dimensions);
|
||||
@@ -521,7 +511,7 @@ describe('iD.Features', function() {
|
||||
var a = iD.osmNode({id: 'a', version: 1});
|
||||
var graph = iD.coreGraph([a]);
|
||||
var ageo = a.geometry(graph);
|
||||
var all = _values(graph.base().entities);
|
||||
var all = Object.values(graph.base().entities);
|
||||
|
||||
features.disable('points');
|
||||
features.gatherStats(all, graph, dimensions);
|
||||
@@ -539,7 +529,7 @@ describe('iD.Features', function() {
|
||||
graph.rebase([iD.osmNode({version: 1})], [graph]);
|
||||
}
|
||||
|
||||
all = _values(graph.base().entities);
|
||||
all = Object.values(graph.base().entities);
|
||||
features.gatherStats(all, graph, dimensions);
|
||||
hidden = features.hidden();
|
||||
autoHidden = features.autoHidden();
|
||||
@@ -550,7 +540,7 @@ describe('iD.Features', function() {
|
||||
|
||||
graph.rebase([iD.osmNode({version: 1})], [graph]);
|
||||
|
||||
all = _values(graph.base().entities);
|
||||
all = Object.values(graph.base().entities);
|
||||
features.gatherStats(all, graph, dimensions);
|
||||
hidden = features.hidden();
|
||||
autoHidden = features.autoHidden();
|
||||
@@ -570,7 +560,7 @@ describe('iD.Features', function() {
|
||||
graph.rebase([iD.osmNode({version: 1})], [graph]);
|
||||
}
|
||||
|
||||
all = _values(graph.base().entities);
|
||||
all = Object.values(graph.base().entities);
|
||||
features.gatherStats(all, graph, dimensions);
|
||||
hidden = features.hidden();
|
||||
autoHidden = features.autoHidden();
|
||||
@@ -581,7 +571,7 @@ describe('iD.Features', function() {
|
||||
|
||||
graph.rebase([iD.osmNode({version: 1})], [graph]);
|
||||
|
||||
all = _values(graph.base().entities);
|
||||
all = Object.values(graph.base().entities);
|
||||
features.gatherStats(all, graph, dimensions);
|
||||
hidden = features.hidden();
|
||||
autoHidden = features.autoHidden();
|
||||
|
||||
@@ -44,30 +44,3 @@ if (!Object.getOwnPropertySymbols) {
|
||||
value: function() { return []; }
|
||||
});
|
||||
}
|
||||
|
||||
// Array.find polyfill (For PhantomJS / IE11)
|
||||
// https://tc39.github.io/ecma262/#sec-array.prototype.find
|
||||
if (!Array.prototype.find) {
|
||||
Object.defineProperty(Array.prototype, 'find', {
|
||||
value: function(predicate) {
|
||||
if (this == null) {
|
||||
throw new TypeError('"this" is null or not defined');
|
||||
}
|
||||
var o = Object(this);
|
||||
var len = o.length >>> 0;
|
||||
if (typeof predicate !== 'function') {
|
||||
throw new TypeError('predicate must be a function');
|
||||
}
|
||||
var thisArg = arguments[1];
|
||||
var k = 0;
|
||||
while (k < len) {
|
||||
var kValue = o[k];
|
||||
if (predicate.call(thisArg, kValue, k, o)) {
|
||||
return kValue;
|
||||
}
|
||||
k++;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user