move phantomjs check for touch into Leaflet

to allow standalone mocha-phantomjs usage on the browser reporter
This commit is contained in:
Vladimir Agafonkin 2013-04-05 12:32:19 +03:00
parent bde0692236
commit 6009d4ae87
4 changed files with 7 additions and 9 deletions

View File

@ -13,7 +13,6 @@ files = [].concat([
"../node_modules/mocha/mocha.js", "../node_modules/mocha/mocha.js",
MOCHA_ADAPTER, MOCHA_ADAPTER,
"before.js", "before.js",
"karma.js",
"sinon.js", "sinon.js",
"expect.js" "expect.js"
], libSources, [ ], libSources, [

View File

@ -1,7 +0,0 @@
// PhantomJS has `'ontouchstart' in document.documentElement`, but
// doesn't actually support touch. So force touch not to be used.
//
// http://code.google.com/p/phantomjs/issues/detail?id=375
// https://github.com/ariya/phantomjs/pull/408
// https://github.com/Leaflet/Leaflet/pull/1434#issuecomment-13843151
window.L_NO_TOUCH = true;

View File

@ -35,13 +35,16 @@ describe("Map", function () {
var container = document.createElement('div'), var container = document.createElement('div'),
map = new L.Map(container).setView([0, 0], 1), map = new L.Map(container).setView([0, 0], 1),
spy = sinon.spy(); spy = sinon.spy();
map.on('click dblclick mousedown mouseup mousemove', spy); map.on('click dblclick mousedown mouseup mousemove', spy);
map.remove(); map.remove();
happen.click(container); happen.click(container);
happen.dblclick(container); happen.dblclick(container);
happen.mousedown(container); happen.mousedown(container);
happen.mouseup(container); happen.mouseup(container);
happen.mousemove(container); happen.mousemove(container);
expect(spy.called).to.not.be.ok(); expect(spy.called).to.not.be.ok();
}); });
}); });

View File

@ -32,7 +32,10 @@
any3d = !window.L_DISABLE_3D && (ie3d || webkit3d || gecko3d || opera3d) && !phantomjs; any3d = !window.L_DISABLE_3D && (ie3d || webkit3d || gecko3d || opera3d) && !phantomjs;
var touch = !window.L_NO_TOUCH && (function () { // PhantomJS has 'ontouchstart' in document.documentElement, but doesn't actually support touch.
// https://github.com/Leaflet/Leaflet/pull/1434#issuecomment-13843151
var touch = !window.L_NO_TOUCH && !phantomjs && (function () {
var startName = 'ontouchstart'; var startName = 'ontouchstart';