备忘一下, 采集详情页重构需要的内容如下:

closest

目录Index

  • closest - element-closest-polyfill
  • fetch

closest - element-closest-polyfill

参考 idmadj/element-closest-polyfill

  1. if (!Element.prototype.matches) {
  2. Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
  3. }
  4. if (!Element.prototype.closest) {
  5. Element.prototype.closest = function (s) {
  6. var el = this;
  7. do {
  8. if (el.matches(s)) return el;
  9. el = el.parentElement || el.parentNode;
  10. } while (el !== null && el.nodeType === 1);
  11. return null;
  12. };
  13. }