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

Validate container option #5695

Merged
merged 2 commits into from
Nov 21, 2017
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
1 change: 1 addition & 0 deletions flow-typed/window.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ declare interface Window extends EventTarget, IDBEnvironment {

Blob: typeof Blob;
HTMLImageElement: typeof HTMLImageElement;
HTMLElement: typeof HTMLElement;
HTMLVideoElement: typeof HTMLVideoElement;
HTMLCanvasElement: typeof HTMLCanvasElement;
Image: typeof Image;
Expand Down
6 changes: 4 additions & 2 deletions src/ui/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const util = require('../util/util');
const browser = require('../util/browser');
const window = require('../util/window');
const {HTMLImageElement} = require('../util/window');
const {HTMLImageElement, HTMLElement} = require('../util/window');
const DOM = require('../util/dom');
const ajax = require('../util/ajax');

Expand Down Expand Up @@ -282,8 +282,10 @@ class Map extends Camera {
} else {
this._container = container;
}
} else {
} else if (options.container instanceof HTMLElement) {
this._container = options.container;
} else {
throw new Error(`Invalid type: 'container' must be a String or HTMLElement.`);
}

this.animationLoop = new AnimationLoop();
Expand Down