From 9a0a4f17a42d15c1d228c4e3ec845291d1123b5c Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Tue, 14 Mar 2017 15:27:05 -0600 Subject: [PATCH] Remove selectionToGFM --- app/assets/javascripts/copy_as_gfm.js | 7 ------- spec/features/copy_as_gfm_spec.rb | 9 +++++++-- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/app/assets/javascripts/copy_as_gfm.js b/app/assets/javascripts/copy_as_gfm.js index 67f7226fe82..570799c030e 100644 --- a/app/assets/javascripts/copy_as_gfm.js +++ b/app/assets/javascripts/copy_as_gfm.js @@ -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 ''; diff --git a/spec/features/copy_as_gfm_spec.rb b/spec/features/copy_as_gfm_spec.rb index 45f3213c308..ce34f48aaaf 100644 --- a/spec/features/copy_as_gfm_spec.rb +++ b/spec/features/copy_as_gfm_spec.rb @@ -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)