"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = getClosestTitleElement;

function getClosestTitleElement(element) {
  var titleElement = null;

  if (element.hasAttribute('data-title') || element.hasAttribute('title')) {
    titleElement = element;
  } else {
    var closedTitleElement = element.closest('[data-title]') || element.closest('[title]');

    if (closedTitleElement) {
      titleElement = closedTitleElement;
    }
  }

  return titleElement;
}