He estado tratando de hacer algo de html y css, pero hasta ahora soy muy malo en esto. Estaba usando una función que verificaría si dos selectores coinciden. A un amigo mío se le ocurrió este código, pero ninguno de nosotros comprende completamente cómo funciona el retorno del caso "tag.class". Mi pregunta es, si no divide el newSelector, ¿cómo puede verificar con éxito la etiqueta y la clase?
var matchFunctionMaker = function(selector) { var selectorType = selectorTypeMatcher(selector); var matchFunction; if (selectorType === "id") { matchFunction = nuevoSelector => '#' + nuevoSelector.id === selector; } else if (selectorType === "class") { matchFunction = nuevoSelector => { var lista = nuevoSelector.classList; for (let x of lista) { if (selector === '.' + x) return true; } return false; } } else if (selectorType === "tag.class") { matchFunction = nuevoSelector => { var [tag, clase] = selector.split('.'); return matchFunctionMaker(tag) (nuevoSelector) && matchFunctionMaker(`.${clase}`) (nuevoSelector); }; } else if (selectorType === "tag") { matchFunction = nuevoSelector => nuevoSelector.tagName.toLowerCase() === selector.toLowerCase(); } return matchFunction; };¡Gracias por adelantado!