Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function isCanvas (element) {
return isDOM(element) && /canvas/i.test(element.nodeName) && typeof element.getContext === 'function';
}
export default function DOM({ container, hex, origin = Point(0, 0) }) {
if (!isDom(container)) {
console.warn(`Container is not a valid dom node: ${container}.`)
return false
}
Hex.prototype.element(hex.element)
return Object.assign(
Object.create(prototype),
{
origin: Point(origin),
container,
hex
}
)
}
function isElementPresent({ input, target }) {
return isDom(input) || (target && isDom(target))
}
function renderTweet({ input, _services }, { twttr, onLoad }) {
if (!isDom(input)) {
throw new Error("input should be a DOM element to embed tweet.")
}
if (_services.filter(service => service.id === "twitter").length) {
twttr.widgets.load(input)
twttr.events.bind("loaded", onLoad)
}
}
export function placement(place, content, origin) {
const gap = 12;
const dim = dimension(content);
let pos = { top: origin.y, right: origin.x, bottom: origin.y, left: origin.x, width: 0, height: 0 }
if (isDOM(origin)) {
pos = position(origin)
} else if (typeof origin === 'string') {
pos = position(document.getElementById(origin))
}
let offset = { width: dim.width, height: dim.height };
switch(place) {
case 'top': case 'bottom':
offset.left = `${pos.left + (pos.width * 0.5) - (dim.width * 0.5)}px`;
break;
case 'left': case 'right':
offset.top = `${pos.top + (pos.height * 0.5) - (dim.height * 0.5)}px`;
break;
}
switch(place) {
fetch: isBrowser && (window.fetch || window.unfetch),
inlineEmbed: true,
replaceUrl: false,
_embeds: [],
_services: []
}
let { input, plugins = [], preset } = options
if (!input) {
throw new Error(
"You need to pass input element or string in the options object."
)
}
const inputString = isDom(input) ? input.innerHTML : input
this.options = extend({}, defaultOptions, options, {
result: inputString,
plugins: preset ? plugins.concat(preset) : plugins,
inputString
})
}
export function isElement (el) {
return isDom(el)
}
const Inspector = ({ table = false, data, ...rest }) => {
if (table) {
return ;
}
if (isDOM(data)) return ;
return ;
};