diff src/formats/xhtml.js @ 27:8165b83907af

remove bind()
author Franklin Schmidt <fschmidt@gmail.com>
date Wed, 10 Aug 2022 23:48:47 -0600
parents 80bf0adc9efd
children db061869f28f
line wrap: on
line diff
--- a/src/formats/xhtml.js	Tue Aug 09 23:30:24 2022 -0600
+++ b/src/formats/xhtml.js	Wed Aug 10 23:48:47 2022 -0600
@@ -536,32 +536,34 @@
 		 * @return {string}
 		 * @memberOf jQuery.sceditor.plugins.xhtml.prototype
 		 */
-		function toSource(isFragment, html, context) {
-			var xhtml,
-				container = context.createElement('div');
-			container.innerHTML = html;
+		function toSource(isFragment) {
+			return function(html, context) {
+				var xhtml,
+					container = context.createElement('div');
+				container.innerHTML = html;
 
-			css(container, 'visibility', 'hidden');
-			context.body.appendChild(container);
+				css(container, 'visibility', 'hidden');
+				context.body.appendChild(container);
 
-			convertTags(container);
-			removeTags(container);
-			removeAttribs(container);
+				convertTags(container);
+				removeTags(container);
+				removeAttribs(container);
 
-			if (!isFragment) {
-				wrapInlines(container);
-			}
+				if (!isFragment) {
+					wrapInlines(container);
+				}
 
-			xhtml = (new sceditor.XHTMLSerializer()).serialize(container, true);
+				xhtml = (new sceditor.XHTMLSerializer()).serialize(container, true);
+
+				context.body.removeChild(container);
 
-			context.body.removeChild(container);
+				return xhtml;
+			};
+		}
 
-			return xhtml;
-		};
+		base.toSource = toSource(false);
 
-		base.toSource = toSource.bind(null, false);
-
-		base.fragmentToSource = toSource.bind(null, true);;
+		base.fragmentToSource = toSource(true);;
 
 		/**
 		 * Runs all converters for the specified tagName
@@ -588,10 +590,10 @@
 							return;
 						}
 
-						converter.conv.call(base, node);
+						converter.conv(node);
 					});
 				} else if (converter.conv) {
-					converter.conv.call(base, node);
+					converter.conv(node);
 				}
 			});
 		};