Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
sync between attributes and properties #1579
Comments
|
You give so many code lines =) What you'd like to add? There's a note about syncing properties that it happens one way sometimes. |
|
Probably it's best to keep it as it is. I just wanted to say that: after changing a property, further manipulation on a corresponding attribute has no effect on the property. |
|
Are you sure? Is that in the spec? |
|
It's just my observation. I hope it is more clear than my previous example. let's say we have the html <input id='field' value='initial'/>And the js const field = document.getElementById('field');
console.log(field.value); // initial
// there is no sync here: I only change a value property, value attr is still intact
field.value='further altering a value attr has no effect on the value property';
console.log(field.getAttribute('value')); // 'initial'
field.setAttribute('value', "I can't change the value property by setting a value attr")
// further altering a value attr has no effect on the value property
console.log(field.value); |
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
go to the website