Remove selectionToGFM

This commit is contained in:
Douwe Maan 2017-03-14 15:27:05 -06:00
parent f90909307e
commit 9a0a4f17a4
2 changed files with 7 additions and 9 deletions

View file

@ -343,13 +343,6 @@ class CopyAsGFM {
return codeEl;
}
static selectionToGFM(documentFragment, transformer) {
const el = transformer(documentFragment.cloneNode(true));
if (!el) return null;
return CopyAsGFM.nodeToGFM(el);
}
static nodeToGFM(node) {
if (node.nodeType === Node.COMMENT_NODE) {
return '';

View file

@ -579,10 +579,15 @@ describe 'Copy as GFM', feature: true, js: true do
def html_to_gfm(html, transformer = 'transformGFMSelection')
js = <<-JS.strip_heredoc
(function(html) {
var transformer = window.gl.CopyAsGFM[#{transformer.inspect}];
var node = document.createElement('div');
node.innerHTML = html;
var transformer = window.gl.CopyAsGFM[#{transformer.inspect}];
return window.gl.CopyAsGFM.selectionToGFM(node, transformer);
node = transformer(node);
if (!node) return null;
return window.gl.CopyAsGFM.nodeToGFM(node);
})("#{escape_javascript(html)}")
JS
page.evaluate_script(js)