Revision: 3896
Author: metaweta
Date: Tue Dec 8 16:50:45 2009
Log: Fixes issue 1154, selectEl.options.selectedIndex.
http://codereview.appspot.com/166045
Exposes the selectedIndex property on an options nodelist.
[email protected]
http://code.google.com/p/google-caja/source/detail?r=3896
Modified:
/trunk/src/com/google/caja/plugin/domita.js
/trunk/tests/com/google/caja/plugin/domita_test_untrusted.html
=======================================
--- /trunk/src/com/google/caja/plugin/domita.js Fri Nov 13 11:43:08 2009
+++ /trunk/src/com/google/caja/plugin/domita.js Tue Dec 8 16:50:45 2009
@@ -1178,6 +1178,13 @@
return ___.freeze(
mixinNodeList([], nodeList, editable, opt_tameNodeCtor));
}
+
+ function tameOptionsList(nodeList, editable, opt_tameNodeCtor) {
+ var nl = mixinNodeList([], nodeList, editable, opt_tameNodeCtor);
+ nl.selectedIndex = +nodeList.selectedIndex;
+ ___.grantRead(nl, 'selectedIndex');
+ return ___.freeze(nl);
+ }
/**
* Return a fake node list containing tamed nodes.
@@ -2506,7 +2513,7 @@
return newValue;
};
TameInputElement.prototype.getOptions = function () {
- return tameNodeList(
+ return tameOptionsList(
this.node___.options, this.editable___, defaultTameNode, 'name');
};
TameInputElement.prototype.getDefaultSelected = function () {
=======================================
--- /trunk/tests/com/google/caja/plugin/domita_test_untrusted.html Mon Nov
23 15:51:54 2009
+++ /trunk/tests/com/google/caja/plugin/domita_test_untrusted.html Tue Dec
8 16:50:45 2009
@@ -459,6 +459,14 @@
duck-4
</div>
+<div class="testcontainer" id="test-selected-index">Test selectedIndex
+ <select id="test-selected-index-1">
+ <option value="0">Zeroth</option>
+ <option value="1">First</option>
+ <option selected value="2">Second</option>
+ </select>
+</div>
+
<p class="waiting testcontainer" id="xhr-module-loader">XHR Module
Loader</p>
<p class="waiting testcontainer" id="script-module-loader">Script Module
Loader</p>
@@ -3256,6 +3264,13 @@
pass('test-focus-blur');
});
+jsunitRegister('testSelectedIndex',
+ function testSelectedIndex() {
+ assertEquals(2, document.getElementById('test-selected-index-1').
+ options.selectedIndex);
+ pass('test-selected-index');
+});
+
// form:onreset uses the same logic path as input:onfocus
jsunitRegister('testOnReset',
function testOnReset() {