UNPKG

@enact/ui

Version:

A collection of simplified unstyled cross-platform UI components for Enact

58 lines (52 loc) 2.24 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.utilDOM = exports["default"] = void 0; var _warning = _interopRequireDefault(require("warning")); function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; } // At the end, wes should not use DOM APIs as well as the APIs in the `utilDOM`. If we use them, we have to try to remove them first if possible. var utilDOM = exports.utilDOM = function () { // Functions function containsDangerously(ref, target) { var _ref$current; if (!target) { return false; } else if (typeof (ref === null || ref === void 0 || (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.contains) === 'function') { process.env.NODE_ENV !== "production" ? (0, _warning["default"])(ref.current.contains, 'The `contains` function of the Ref is not supported.') : void 0; return ref.current.contains(target); } else if (typeof (ref === null || ref === void 0 ? void 0 : ref.contains) === 'function') { process.env.NODE_ENV !== "production" ? (0, _warning["default"])(ref.contains, 'The `contains` function of the Ref is not supported.') : void 0; return ref.contains(target); } return false; } // TBD // Need to define functions for the following DOM APIs // getBoundingClientRect // dataset.spotlightId // getRect // setAttribute // removeAttribute // scrollLeft // scrollTop function datasetDangerously() {} function getBoundingClientRectDangerously() {} function getRectDangerously() {} function removeAttributeDangerously() {} function setAttributeDangerously() {} var scrollLeftDangerously = 0; var scrollTopDangerously = 0; // Return return { containsDangerously: containsDangerously, datasetDangerously: datasetDangerously, getBoundingClientRectDangerously: getBoundingClientRectDangerously, getRectDangerously: getRectDangerously, removeAttributeDangerously: removeAttributeDangerously, scrollLeftDangerously: scrollLeftDangerously, scrollTopDangerously: scrollTopDangerously, setAttributeDangerously: setAttributeDangerously }; }(); var _default = exports["default"] = utilDOM;