Author: nbelaevski
Date: 2008-08-31 14:48:37 -0400 (Sun, 31 Aug 2008)
New Revision: 10250
Modified:
trunk/framework/impl/src/main/resources/org/richfaces/renderkit/html/scripts/utils.js
Log:
Added methods:
- Richfaces.readAttribute
- Richfaces.writeAttribute
Modified:
trunk/framework/impl/src/main/resources/org/richfaces/renderkit/html/scripts/utils.js
===================================================================
---
trunk/framework/impl/src/main/resources/org/richfaces/renderkit/html/scripts/utils.js 2008-08-30
22:44:13 UTC (rev 10249)
+++
trunk/framework/impl/src/main/resources/org/richfaces/renderkit/html/scripts/utils.js 2008-08-31
18:48:37 UTC (rev 10250)
@@ -401,4 +401,33 @@
parentNode.removeChild(node);
}
}
+};
+
+Richfaces.readAttribute = function(element, name) {
+ var result = null;
+
+ var node = element.getAttributeNode(name);
+ if (node) {
+ result = node.nodeValue;
+ }
+
+ return result;
+};
+
+Richfaces.writeAttribute = function(element, name, value) {
+ var node = element.getAttributeNode(name);
+
+ if (value !== null) {
+ if (node) {
+ node.nodeValue = value;
+ } else {
+ node = document.createAttribute(name);
+ node.nodeValue = value;
+ element.setAttributeNode(node);
+ }
+ } else {
+ if (node) {
+ element.removeAttributeNode(node);
+ }
+ }
};
\ No newline at end of file
Show replies by date