javascript-tutorial / javascript-tutorial/en.javascript.info
sync between attributes and properties
- Linguagem predominante
- HTML
- Estrelas
- 25.5k
- Forks
- 4k
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Descrição
> But there are exclusions, for instance input.value synchronizes only from attribute → to property, but not back:
I don't know is it worth or not to mention (as a side note) that the sync between attributes and properties is *not* going to happen *after* a property is assigned directly. Example
```javascript
let inp = document.getElementById('search');
inp.setAttribute('value','initialValue');
inp.value === 'initialValue'; //true
inp.setAttribute('value','changedValue via setAttribute');
inp.value === 'changedValue via setAttribute'; // true;
inp.value = 'cancel all consecutive attempts to sync via setAttribute';
inp.value === 'cancel all consecutive attempts to sync via setAttribute'; // true
inp.setAttribute('value','has no effect on input.value');
inp.value === 'has no effect on input.value'; // false
inp.value === 'cancel all consecutive attempts to sync via setAttribute'; // true
```
[go to the website](https://javascript.info/dom-attributes-and-properties#property-attribute-synchronization)
Guia de contribuição
Nenhum guia de contribuição indexado para este repositório
Direção de pesquisa
Comece pela seção vinculada sobre atributos e propriedades do DOM, especialmente pelo exemplo de sincronização entre propriedade e atributo. Esclareça o comportamento documentado após atribuir diretamente a input.value e atualize a seção se a ressalva sobre a sincronização unidirecional pertencer a ela; o trabalho estará concluído quando o exemplo explicar corretamente por que chamadas posteriores a setAttribute não alteram input.value.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- javascript
- Domínio
- documentation
- Tipo de issue
- Documentação
- Dificuldade
- 1/5
- Tempo estimado
- Menos de uma hora
- Status de atividade
- Estagnada
- Clareza
- Razoavelmente clara
- Facilidade para iniciantes
- 45/100