Source: map-common/src/main/resources/META-INF/resources/js/validators.es.js

  1. /**
  2. * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
  3. *
  4. * This library is free software; you can redistribute it and/or modify it under
  5. * the terms of the GNU Lesser General Public License as published by the Free
  6. * Software Foundation; either version 2.1 of the License, or (at your option)
  7. * any later version.
  8. *
  9. * This library is distributed in the hope that it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  11. * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
  12. * details.
  13. */
  14. /**
  15. * Checks if the given node is an instance of HTMLInputElement.
  16. * @param {*} node Node to be tested
  17. * @return {boolean}
  18. * @review
  19. */
  20. function isInputNode(node) {
  21. return node instanceof HTMLInputElement;
  22. }
  23. /**
  24. * Checks if the given set is a subset of the specified superset.
  25. * @param {Array[]} superset Group of valid elements.
  26. * @return {boolean}
  27. * @review
  28. */
  29. function isSubsetOf(superset) {
  30. return (subset) => {
  31. const subsetLength = subset.length;
  32. for (let i = 0; i < subsetLength; i++) {
  33. if (superset.indexOf(subset[i]) === -1) {
  34. return false;
  35. }
  36. }
  37. return true;
  38. };
  39. }
  40. export {isInputNode, isSubsetOf};