refactor(Placeholder.tsx): corrigindo lógica do componente

This commit is contained in:
Ana Carolina Duarte Cavalcante 2023-02-10 18:53:47 -03:00
parent 001887d29e
commit eb070d4a1d

View File

@ -1,16 +1,29 @@
const Placeholder = () => {
if (typeof document !== "undefined") {
const observer = new MutationObserver(mutations => {
mutations.forEach(_mutation => {
const postalCodeInput = document.querySelector(
".vtex-address-form-4-x-input"
);
const postalCodeValue = document.querySelector(".postalCode");
if (postalCodeInput) {
postalCodeInput.classList.add("postalCode");
observer.disconnect();
}
if (postalCodeValue) {
postalCodeValue.setAttribute("placeholder", "Digite seu CEP");
}
});
});
observer.observe(document, {
childList: true,
subtree: true
});
}
return null;
};