Details

    • Task
    • Status: Closed
    • Minor
    • Resolution: Completed
    • None
    • None
    • Metal.js
    • None

    Description

      Part of our plan to Remove usages of metal-dom in DXP codebase.

      The goal of this task is to remove all usages of toElement from the metal-dom package.

      To this day, there's no standard way to replace our current implementation of toElement:

      export function toElement(selectorOrElement) {
      	if (
      		isElement(selectorOrElement) ||
      		isDocument(selectorOrElement) ||
      		isDocumentFragment(selectorOrElement)
      	) {
      		return selectorOrElement;
      	} else if (isString(selectorOrElement)) {
      		return document.querySelector(selectorOrElement);
      	} else {
      		return null;
      	}
      }
      

      A good amount of usages of toElement can be simply replaced with document.querySelector or simply document.getElementById since they unequivocally always use a selector or identifier.

      The few other cases where an input can be of both types, it should be okay to encode this function somewhere.

      Acceptance Criteria

      • All usages of toElement from metal-dom have been replaced

      Possible occurrences of toElement (Deduped list of modules on git grep 'toElement(' *.js*)

      • modules/apps/frontend-js/frontend-js-web
      • modules/apps/frontend-taglib/frontend-taglib
      • modules/apps/map/map-google-maps
      • modules/apps/map/map-openstreetmap
      • modules/apps/site-navigation/site-navigation-admin-web
      • portal-web/docroot/html/taglib/ui/form_navigator/lexicon/page.jsp

      Attachments

        Activity

          People

            brian.chan Brian Chan
            jose.balsas Chema Balsas (Inactive)
            Bryce Osterhaus Bryce Osterhaus
            Kiyoshi Lee Kiyoshi Lee
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Packages

                Version Package