javascript-tutorial / javascript-tutorial/en.javascript.info

sync between attributes and properties

未關閉
#1,579 4 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
waiting for feedback
主要語言
HTML
星號
25.5k
分支
4k
PR 合併指標
30 天內沒有已合併 PR

描述

> 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)

貢獻指南

這個儲存庫沒有索引到貢獻指南

研究方向

從連結的 DOM attributes 和 properties 區段開始,尤其是 property-attribute synchronization 範例。釐清直接指定 input.value 後文件所述的行為,然後在單向同步的注意事項應放在該區段時更新該區段;完成的標準是範例準確解釋為什麼之後呼叫 setAttribute 不會變更 input.value。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
javascript
領域
documentation
Issue 類型
文件
難度
1/5
預估耗時
1 小時以內
活躍度
停滯
描述清晰度
基本清楚
新手友好度
45/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。