39 lines
1.1 KiB
JavaScript
39 lines
1.1 KiB
JavaScript
goog.provide("goog.dom.asserts");
|
|
goog.require("goog.asserts");
|
|
goog.dom.asserts.assertIsLocation = function(o) {
|
|
if (goog.asserts.ENABLE_ASSERTS) {
|
|
var win = goog.dom.asserts.getWindow_(o);
|
|
if (win) {
|
|
if (!o || !(o instanceof win.Location) && o instanceof win.Element) {
|
|
goog.asserts.fail("Argument is not a Location (or a non-Element mock); got: %s", goog.dom.asserts.debugStringForType_(o));
|
|
}
|
|
}
|
|
}
|
|
return o;
|
|
};
|
|
goog.dom.asserts.debugStringForType_ = function(value) {
|
|
if (goog.isObject(value)) {
|
|
try {
|
|
return value.constructor.displayName || value.constructor.name || Object.prototype.toString.call(value);
|
|
} catch (e) {
|
|
return "\x3cobject could not be stringified\x3e";
|
|
}
|
|
} else {
|
|
return value === undefined ? "undefined" : value === null ? "null" : typeof value;
|
|
}
|
|
};
|
|
goog.dom.asserts.getWindow_ = function(o) {
|
|
try {
|
|
var doc = o && o.ownerDocument;
|
|
var win = doc && (doc.defaultView || doc.parentWindow);
|
|
win = win || goog.global;
|
|
if (win.Element && win.Location) {
|
|
return win;
|
|
}
|
|
} catch (ex) {
|
|
}
|
|
return null;
|
|
};
|
|
|
|
//# sourceMappingURL=goog.dom.asserts.js.map
|