FIX: fails gracefully if :scope is not handled by a browser (#9529)

FIX: fails gracefully if :scope is not handled by a browser (#9529)

diff --git a/app/assets/javascripts/discourse/app/initializers/copy-codeblocks.js b/app/assets/javascripts/discourse/app/initializers/copy-codeblocks.js
index f7e81af..62552f6 100644
--- a/app/assets/javascripts/discourse/app/initializers/copy-codeblocks.js
+++ b/app/assets/javascripts/discourse/app/initializers/copy-codeblocks.js
@@ -113,9 +113,15 @@ export default {
           return;
         }
 
-        const commands = postElements[0].querySelectorAll(
-          ":scope > pre > code, :scope :not(article):not(blockquote) > pre > code"
-        );
+        let commands = [];
+        try {
+          commands = postElements[0].querySelectorAll(
+            ":scope > pre > code, :scope :not(article):not(blockquote) > pre > code"
+          );
+        } catch (e) {
+          // :scope is probably not supported by this browser
+          commands = [];
+        }
 
         const post = helper.getModel();
 

GitHub sha: be1b7f74

This commit appears in #9529 which was approved by davidtaylorhq. It was merged by jjaffeux.