JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.2.1
[ckeditor.git] / _source / core / tools.js
index 0fd703f..fc82904 100644 (file)
@@ -323,6 +323,19 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                },\r
 \r
                /**\r
+                * Replace special HTML characters in HTMLElement's attribute with their relative HTML entity values.\r
+                * @param {String} The attribute's value to be encoded.\r
+                * @returns {String} The encode value.\r
+                * @example\r
+                * element.setAttribute( 'title', '<a " b >' );\r
+                * alert( CKEDITOR.tools.htmlEncodeAttr( element.getAttribute( 'title' ) );  // "&gt;a &quot; b &lt;"\r
+                */\r
+               htmlEncodeAttr : function( text )\r
+               {\r
+                       return text.replace( /"/g, '&quot;' ).replace( /</g, '&lt;' ).replace( />/, '&gt;' );\r
+               },\r
+\r
+               /**\r
                 * Replace characters can't be represented through CSS Selectors string\r
                 * by CSS Escape Notation where the character escape sequence consists\r
                 * of a backslash character (\) followed by the orginal characters.\r
@@ -540,7 +553,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                 * <li> Public (prototype) fields </li>\r
                 * <li> Chainable base class constructor </li>\r
                 * </ul>\r
-                * @param {Object} definiton The class definiton object.\r
+                * @param {Object} definition The class definition object.\r
                 * @returns {Function} A class-like JavaScript function.\r
                 */\r
                createClass : function( definition )\r