You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shindig.apache.org by ch...@gmail.com on 2010/07/15 21:39:12 UTC

SHINDIG-1378: Caja removes unknown attributes in os:PeopleSelector (issue1715049)

Reviewers: dev-remailer_shindig.apache.org, jasvir,

Description:
The os:PeopleSelector tag definition generates the following attributes
in the select tag which are stripped by Caja:
x-var
x-max
x-onselect

The fix is to move this data into the constructor.

Messages from Caja:
stdin:stdin:62: elect" onchange="os_PeopleSelector_onchange(this)"
x-max="2" x-onselect=""
x-var


WARNING: stdin:stdin:62+123 - 128: removing unknown attribute x-var on
select
stdin:stdin:62: ="peopleSelect"
onchange="os_PeopleSelector_onchange(this)" x-max="2" x-onselect

WARNING: stdin:stdin:62+109 - 119: removing unknown attribute x-onselect
on select
stdin:stdin:62: "multiple" name="peopleSelect"
onchange="os_PeopleSelector_onchange(this)"
x-max


WARNING: stdin:stdin:62+99 - 104: removing unknown attribute x-max on
select

Caja Issue: http://code.google.com/p/google-caja/issues/detail?id=933
JIRA: https://issues.apache.org/jira/browse/SHINDIG-1378

Please review this at http://codereview.appspot.com/1715049/show

Affected files:
   OSML_library.xml


Index: OSML_library.xml
===================================================================
--- OSML_library.xml	(revision 964271)
+++ OSML_library.xml	(working copy)
@@ -36,17 +36,14 @@
    </Template>
    <TemplateDef tag="os:PeopleSelector">
      <Template>
-      <select onchange="os_PeopleSelector_onchange(this)"
+      <select onchange="os_PeopleSelector_onchange(this, ${My.var ?  
My.var : false}, ${My.max ? My.max : 0}, ${My.onselect ? My.onselect :  
false})"
            name="${My.inputName}"
-          multiple="${My.multiple}"
-          x-var="${My.var}"
-          x-max="${My.max}"
-          x-onselect="${My.onselect}">
+          multiple="${My.multiple}">
          <option repeat="${My.group}" value="${Cur.id}" selected="${Cur.id  
== My.selected}">${Cur.name.formatted}</option>
        </select>
      </Template>
      <JavaScript><![CDATA[
-        function os_PeopleSelector_onchange(select) {
+        function os_PeopleSelector_onchange(select, varAttr, maxAttr,  
onSelectAttr) {
            var selected;
            if (!select.multiple) {
              selected = select.options[select.selectedIndex].value;
@@ -57,13 +54,12 @@
                  selected.push(select.options[i].value);
                }
              }
-            var max = select.getAttribute("x-max");
              try {
-              max = 1*max;
+              maxAttr = 1*maxAttr;
              } catch (e) {
-              max = 0;
+              maxAttr = 0;
              }
-            if (max && selected.length > max && select['x-selected']) {
+            if (maxAttr && selected.length > maxAttr &&  
select['x-selected']) {
                selected = select['x-selected'];
                for (var i = 0; i < select.options.length; i++) {
                  select.options[i].selected = false;
@@ -77,19 +73,17 @@
              }
            }
            select['x-selected'] = selected;
-          var varAttr = select.getAttribute("x-var");
            if (varAttr) {
              if (opensocial.data) {
                opensocial.data.getDataContext().putDataSet(varAttr,  
selected);
              }
            }
-          var onSelect = select.getAttribute("x-onselect");
-          if (onSelect) {
-            if (window[onSelect] && typeof(window[onSelect])  
== 'function') {
-              window[onSelect](selected);
+          if (onSelectAttr) {
+            if (window[onSelectAttr] && typeof(window[onSelectAttr])  
== 'function') {
+              window[onSelectAttr](selected);
              } else {
                if (!select['x-onselect-fn']) {
-                select['x-onselect-fn'] = new Function(onSelect);
+                select['x-onselect-fn'] = new Function(onSelectAttr);
                }
                select['x-onselect-fn'].apply(select);
              }