<commit_before>// 检查元素是否在某个元素里，与 jQuery.contains 等同
export function contains(container, target) {
  if (target) {
    while ((target = target.parentNode)) {
      if (container === target) {
        return true
      }
    }
  }
  return false
}

// 获取元素到页面左边与顶部的距离，与 jQuery().offset() 结果等同
export function offset(elem) {
  const offset = { left: 0, top: 0 }
  while (elem) {
    offset.left += elem.offsetLeft
    offset.top += elem.offsetTop
    elem = elem.offsetParent
  }
  return offset
}

export function isWindow(elem) {
  return elem != null && elem === elem.window
}

export function getStyle(elem, prop) {
  const style = getComputedStyle(elem)
  return parseFloat(style[prop])
}
<commit_msg>Fix: use Node.contains instead of the "contains" method<commit_after>// 获取元素到页面左边与顶部的距离，与 jQuery().offset() 结果等同
export function offset(elem) {
  const offset = { left: 0, top: 0 }
  while (elem) {
    offset.left += elem.offsetLeft
    offset.top += elem.offsetTop
    elem = elem.offsetParent
  }
  return offset
}

export function isWindow(elem) {
  return elem != null && elem === elem.window
}

export function getStyle(elem, prop) {
  const style = getComputedStyle(elem)
  return parseFloat(style[prop])
}

{'fraction_non_alphanumeric': 0.12335526315789473, 'fraction_numerical': 0.003289473684210526, 'mean_word_length': 3.541044776119403, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '460202', 'n_tokens_mistral': 421, 'n_tokens_neox': 436, 'n_words': 106}