MCPcopy Index your code
hub / github.com/phaserjs/phaser / GetTarget

Function GetTarget

src/dom/GetTarget.js:19–45  ·  view source on GitHub ↗
(element)

Source from the content-addressed store, hash-verified

17 * @return {HTMLElement} The DOM element matching the given ID or node reference, or `document.body` if no valid target was found.
18 */
19var GetTarget = function (element)
20{
21 var target;
22
23 if (element !== '')
24 {
25 if (typeof element === 'string')
26 {
27 // Hopefully an element ID
28 target = document.getElementById(element);
29 }
30 else if (element && element.nodeType === 1)
31 {
32 // Quick test for a HTMLElement
33 target = element;
34 }
35 }
36
37 // Fallback to the document body. Covers an invalid ID and a non HTMLElement object.
38 if (!target)
39 {
40 // Use the full window
41 target = document.body;
42 }
43
44 return target;
45};
46
47module.exports = GetTarget;

Callers 1

ScaleManager.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…