web 3d图形渲染器
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.9 KiB

  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.findByTitle = exports.findAllByTitle = exports.getAllByTitle = exports.getByTitle = exports.queryAllByTitle = exports.queryByTitle = void 0;
  6. var _queryHelpers = require("../query-helpers");
  7. var _helpers = require("../helpers");
  8. var _allUtils = require("./all-utils");
  9. const isSvgTitle = node => {
  10. var _node$parentElement;
  11. return node.tagName.toLowerCase() === 'title' && ((_node$parentElement = node.parentElement) == null ? void 0 : _node$parentElement.tagName.toLowerCase()) === 'svg';
  12. };
  13. function queryAllByTitle(container, text, {
  14. exact = true,
  15. collapseWhitespace,
  16. trim,
  17. normalizer
  18. } = {}) {
  19. (0, _helpers.checkContainerType)(container);
  20. const matcher = exact ? _allUtils.matches : _allUtils.fuzzyMatches;
  21. const matchNormalizer = (0, _allUtils.makeNormalizer)({
  22. collapseWhitespace,
  23. trim,
  24. normalizer
  25. });
  26. return Array.from(container.querySelectorAll('[title], svg > title')).filter(node => matcher(node.getAttribute('title'), node, text, matchNormalizer) || isSvgTitle(node) && matcher((0, _allUtils.getNodeText)(node), node, text, matchNormalizer));
  27. }
  28. const getMultipleError = (c, title) => `Found multiple elements with the title: ${title}.`;
  29. const getMissingError = (c, title) => `Unable to find an element with the title: ${title}.`;
  30. const queryAllByTitleWithSuggestions = (0, _queryHelpers.wrapAllByQueryWithSuggestion)(queryAllByTitle, queryAllByTitle.name, 'queryAll');
  31. exports.queryAllByTitle = queryAllByTitleWithSuggestions;
  32. const [queryByTitle, getAllByTitle, getByTitle, findAllByTitle, findByTitle] = (0, _allUtils.buildQueries)(queryAllByTitle, getMultipleError, getMissingError);
  33. exports.findByTitle = findByTitle;
  34. exports.findAllByTitle = findAllByTitle;
  35. exports.getByTitle = getByTitle;
  36. exports.getAllByTitle = getAllByTitle;
  37. exports.queryByTitle = queryByTitle;