Skip to content

Instantly share code, notes, and snippets.

@godmar
Created September 7, 2012 21:04
Show Gist options
  • Save godmar/3669613 to your computer and use it in GitHub Desktop.
Save godmar/3669613 to your computer and use it in GitHub Desktop.
possible fix for checked attribute
diff --git a/lib/jsdom/level2/html.js b/lib/jsdom/level2/html.js
index 6d92a8f..ae7e38a 100644
--- a/lib/jsdom/level2/html.js
+++ b/lib/jsdom/level2/html.js
@@ -848,11 +848,14 @@ define('HTMLInputElement', {
return this._initDefaultChecked();
},
get checked() {
- return !!this.getAttribute('checked');
+ return !!this._attributes.getNamedItem('checked');
},
set checked(checked) {
this._initDefaultChecked();
- this.setAttribute('checked', checked);
+ if (checked)
+ this.setAttribute('checked', 'checked');
+ else
+ this.removeAttribute('checked');
},
get value() {
return this.getAttribute('value');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment