Mercurial Hosting > sceditor
comparison 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 |
comparison
equal
deleted
inserted
replaced
26:160be99e1517 | 27:8165b83907af |
---|---|
534 * @param {Document} context | 534 * @param {Document} context |
535 * @param {HTMLElement} [parent] | 535 * @param {HTMLElement} [parent] |
536 * @return {string} | 536 * @return {string} |
537 * @memberOf jQuery.sceditor.plugins.xhtml.prototype | 537 * @memberOf jQuery.sceditor.plugins.xhtml.prototype |
538 */ | 538 */ |
539 function toSource(isFragment, html, context) { | 539 function toSource(isFragment) { |
540 var xhtml, | 540 return function(html, context) { |
541 container = context.createElement('div'); | 541 var xhtml, |
542 container.innerHTML = html; | 542 container = context.createElement('div'); |
543 | 543 container.innerHTML = html; |
544 css(container, 'visibility', 'hidden'); | 544 |
545 context.body.appendChild(container); | 545 css(container, 'visibility', 'hidden'); |
546 | 546 context.body.appendChild(container); |
547 convertTags(container); | 547 |
548 removeTags(container); | 548 convertTags(container); |
549 removeAttribs(container); | 549 removeTags(container); |
550 | 550 removeAttribs(container); |
551 if (!isFragment) { | 551 |
552 wrapInlines(container); | 552 if (!isFragment) { |
553 } | 553 wrapInlines(container); |
554 | 554 } |
555 xhtml = (new sceditor.XHTMLSerializer()).serialize(container, true); | 555 |
556 | 556 xhtml = (new sceditor.XHTMLSerializer()).serialize(container, true); |
557 context.body.removeChild(container); | 557 |
558 | 558 context.body.removeChild(container); |
559 return xhtml; | 559 |
560 }; | 560 return xhtml; |
561 | 561 }; |
562 base.toSource = toSource.bind(null, false); | 562 } |
563 | 563 |
564 base.fragmentToSource = toSource.bind(null, true);; | 564 base.toSource = toSource(false); |
565 | |
566 base.fragmentToSource = toSource(true);; | |
565 | 567 |
566 /** | 568 /** |
567 * Runs all converters for the specified tagName | 569 * Runs all converters for the specified tagName |
568 * against the DOM node. | 570 * against the DOM node. |
569 * @param {string} tagName | 571 * @param {string} tagName |
586 | 588 |
587 if (!attr || values && values.indexOf(attr.value) < 0) { | 589 if (!attr || values && values.indexOf(attr.value) < 0) { |
588 return; | 590 return; |
589 } | 591 } |
590 | 592 |
591 converter.conv.call(base, node); | 593 converter.conv(node); |
592 }); | 594 }); |
593 } else if (converter.conv) { | 595 } else if (converter.conv) { |
594 converter.conv.call(base, node); | 596 converter.conv(node); |
595 } | 597 } |
596 }); | 598 }); |
597 }; | 599 }; |
598 | 600 |
599 /** | 601 /** |