


??? ?? ?? ??: Dominando customElements.define() ? .get() como um Jedi do Front-end!
Nov 01, 2024 am 08:59 AM?????, ??? ???! ??? ?? ??? ??? ? ??? ????? ?? ??? ?? ????? Jedi? ????? ?? ?? ??? customElements.define() ? customElements.get()? ??? ?? ??? ??? ????!
?? customElements.define(): ??? ??? ???... ? ??, Element!
??? ?? ????? ????? ???? HTML ???? ??? ??? ??? ???. ??? ?? customElements.define()? ???? ????. ? Mewtwo ???? ????? ? ??????!
class ElementoTopzera extends HTMLElement { constructor() { super(); this.innerHTML = `<p>Eu sou incrível e customizado!</p>`; } } customElements.define('elemento-topzera', ElementoTopzera);
?? ??? ?? HTML? ?? ??? ??? ? ????.
<elemento-topzera></elemento-topzera>
?! ? ?? DOM? ??? ???????!
??♂? ??? ????? ?? ??? ? ? ?? ??? ?
- ??? ?? ?? ??? ?? ??? ??? ???. ???? ?? ???? ???? ???? ????!
class BotaoContador extends HTMLElement { constructor() { super(); this.count = 0; this.innerHTML = ` <button>Cliques: <span>0</span></button> `; this.addEventListener('click', () => { this.count++; this.querySelector('span').textContent = this.count; }); } } customElements.define('botao-contador', BotaoContador);
- ??? ?? RPG ????? ? ?????? ??? ??? ??!
class CardPerfil extends HTMLElement { constructor() { super(); const nome = this.getAttribute('nome') || 'Dev An?nimo'; const skill = this.getAttribute('skill') || 'Café++'; this.innerHTML = ` <div style="border: 2px solid #333; padding: 10px; margin: 10px;"> <h2>${nome}</h2> <p>Skill Suprema: ${skill}</p> </div> `; } } customElements.define('card-perfil', CardPerfil);
??? ?????.
<card-perfil nome="ZézimDev" skill="Bug Hunter"></card-perfil>
???♂? customElements.get(): ??? ?? ??
?? ?? ??? ?? ????? ???? ??? ??? ?? ???? ??? ?? ? ???? ??? ????? customElements.get()? ???? ????!
const ElementoTopzera = customElements.get('elemento-topzera'); if (ElementoTopzera) { console.log('Elemento encontrado! Hora do show!'); // Faz alguma mágica aqui } else { console.log('404 Elemento Not Found'); }
?? 80?? ?????? ?? ?? ??
- ???? ?? ?? ??? ?? ?? ??? ???? ?????? ????? ??? ????? ????? ?? ??? ? ?? ???? ??? ? ????.
function carregaComponenteSeNecessario(nomeElemento) { if (!customElements.get(nomeElemento)) { import(`./components/${nomeElemento}.js`) .then(() => console.log(`${nomeElemento} carregado e pronto pra a??o!`)) .catch(err => console.error(`Oops, deu ruim ao carregar ${nomeElemento}`, err)); } } carregaComponenteSeNecessario('super-tabela');
- ???? ?? ??? ??? ??? ????? ???? ?? ??? ??????.
function elementoSeguro(nomeElemento) { const elemento = customElements.get(nomeElemento); if (elemento && elemento.prototype instanceof HTMLElement) { console.log('Elemento verificado e aprovado! ?'); return true; } console.warn('Elemento suspeito detectado! ?'); return false; } elementoSeguro('botao-contador'); // true, se definido anteriormente elementoSeguro('virus-malicioso'); // false, espero eu! ?
? ????? ??? ??????? ??
- ??? ??: ?? ???? ??? ??? ?? ?? ??? ?????. ??? ??? ?? ?????!
- ?? ??: DOM? ???? ???? ??? ???? ?? ?? customElements.get()? ?????.
- ???? ?????: ?? ???? ?????? ?? ?? ??:
class SuperButton extends HTMLButtonElement { // Código supimpa aqui } customElements.define('super-button', SuperButton, { extends: 'button' });
? ??? ??? ?????!
customElements.define() ? customElements.get()? ???? ???? ???? ? ???? ?? ?? ? ????! ?????: ? ??? ??? ?? ??? ?? ? ?? ? ??? ????!
?? ???? ?????! ??? ??? ?? ??? ?????! ??? ??? ???? ???? ?? "??? ????? ??? ????"?? ??????. ??
? ??? ???? ? ?? ???? ?????? MDN? ?? Custom Elements ??? ?????. ????? ???? ???? ????! ??
?????, ????? ???? ??? ??? ???? ?? ?? ??? ?? ??? ??? ??????! ??? ?????
??? ??? ????! ????
? ??? ??? ?? ?? ??: Dominando customElements.define() ? .get() como um Jedi do Front-end!? ?? ?????. ??? ??? PHP ??? ????? ?? ?? ??? ?????!

? AI ??

Undress AI Tool
??? ???? ??

Undresser.AI Undress
???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover
???? ?? ???? ??? AI ?????.

Clothoff.io
AI ? ???

Video Face Swap
??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

?? ??

??? ??

???++7.3.1
???? ?? ?? ?? ???

SublimeText3 ??? ??
??? ??, ???? ?? ????.

???? 13.0.1 ???
??? PHP ?? ?? ??

???? CS6
??? ? ?? ??

SublimeText3 Mac ??
? ??? ?? ?? ?????(SublimeText3)

CSS?? ????? ??? ? ?? ??? ????. 1. HTML ? CSS? ?? ??? ?????? ???? ?? ???? ?? ???? ??????. 2. ?? ??? ??? ?? ???? ???? ?? ?? ??? ?? ?? ??? ??????. 3. ??? ????? ???? JavaScript? ?? ???? ?????? ??? ?????. ? ?? ??? ??? ??? ????? ?? ??, ??, ??? ? ?? ???? ?? ?? ?? ??? ???? ?????.

CSS ???? ??? ? ??? ??? ????? ???? ??? ???? ???? ?? ?? ???? ????? ???????. 1. Flexbox ? ??? ??? ?? ???? ??? ??, ?? : ??? ?? ? ????? ??? ????. 2. Caniuse ?? ?? ?? ??? ??????. 3. -webkit-, -moz-, -ms-, -o- ? ?? ???? ???? ???? ?????. 4. AutoPrefixer? ???? ???? ???? ???? ?? ????. 5. ?? ????? ????? PostCSS? ???? BrowsersList? ??????. 6. ?? ? ???? ???? ?????. 7. Modernizr ?? ??? ??? ????? ??? ? ????. 8. ?? ????? ???? ?? ? ??? ????.

CSS? ?? ?? ??? ??? ??? ???? ???? SVG? ???? ?? ???, ?? ????, ??? ?? ?? ??? ?? ???? ??????. ??? ??? ????. 1. ?, ??, ??? ?? ?? ??? ?? ??? ?????. 2. ?? ?? ? ??? ???? ??? ? ????. 3. ?????? ?? ?? ?? ?? ????? ???? ?? ??? ?? ? ? ????. 4. ???? ???? ??? ??? ??? ????? ?? ? ??? ????. ???? ???? ?? ?? ?? : ? (50pxatcenter) ? ??? ?? ?? : ??? (50%0%, 100 0%, 0%)? ?? ????. ????

themaindifferencesbetweendisplay : ???, ??, andinline-blockinhtml/cssarelayoutbehavior, spaceusage ? stylingcontrol.1.inlineElementsFlowWithText, do n'tStartonnewlines, ingorewidth/height, andonlyapplyhorizontalpadding/margins —IdealforIneTeTexting

??? ?? ???? ???? ??? ??, ?? ??? ??? ? ? ????? ??? ??? ???? ???? ? ? ?? ? ? ????. 1. CSS ?? : ?? ??? ???? ???? ?? ??; 2. ????? ?? ?? ?? ???? ?? ?? ??? ??? ? ????. 3. ?? ??? ??? ??? ??? ?? ?? ???? ????????. 4. ??? ????? ??? ???? ?? ? ??? ??? ?? ??? ?? ?? ??? ????? ???? ?? ????.

CSS? ???? ?? ? ???? ???? ??? ?? ??? ?? ?? ?? ? ? ????. 1. Max width : 100% ? ?? : Auto? ???? ???? ??? ????? ???? ??? ??? ? ??????. 2. HTML? SRCSET ? ?? ??? ???? ?? ??? ??? ??? ??? ???????????. 3. ?? ?? ? ?? ??? ???? ??? ??? ? ?? ?????? ??????. ? ??? ?? ???? ?? ???? ???? ???? ????????.

CSS ??? ??? ?? ?? ?? ? ?? ? ?? ??? ?? ????. 1.px? ?? ??? ????? ?? ??? ??? ?? ??? ?????. 2.EM? ?? ????, ?? ?? ??? ??? ?? ?? ???? ??, REM? ?? ??? ???? ? ????? ??? ????? ?????. 3.VW/VH? ?? ? ???? ??? ??? ??? ??????? ?? ???? ?????? ???????. 4. ??? ?? ?? ? ??, ?? ?? ?? ? ??? ???? ???? ???????. ???? ??? ???? ??? ? ?? ??? ???? ? ????.

?? ????? CSS ?? ??? ????? ?? ?? ??? ??, ?? ?? ?? ??, Flexbox ? ??? ???? ?? ?? ? ?? CSS ??? ????? ??? ???? ???? ?? ????? ??? ?????. 1. ?? ??? ??? ???? ????. ???? CSSRESET ?? NALLER.CSS? ???? ?? ???? ???? ????. 2. IE? ?? ??? ?? ?? ?? ??? ????. ?? ?? : ?? ? ???? ??? ??? ???? ?? ????. 3. Flexbox ? Grid? Edge Case ?? Old ???? ??? ?????. ? ?? ??? ? AutopRefixer ??; 4. ?? CSS ?? ??? ???? ????. Caniuse? ???? ?? ?????????.
