diff --git a/app/assets/javascripts/discourse-common/addon/lib/deprecated.js b/app/assets/javascripts/discourse-common/addon/lib/deprecated.js index bce9aebe86b..cb0e670c88e 100644 --- a/app/assets/javascripts/discourse-common/addon/lib/deprecated.js +++ b/app/assets/javascripts/discourse-common/addon/lib/deprecated.js @@ -52,7 +52,7 @@ export default function deprecated(msg, options = {}) { if ( raiseError || matchedWorkflow?.handler === "throw" || - (!matchedWorkflow && deprecationWorkflow.throwOnUnhandled) + (!matchedWorkflow && deprecationWorkflow?.throwOnUnhandled) ) { throw msg; } diff --git a/spec/lib/pretty_text_spec.rb b/spec/lib/pretty_text_spec.rb index 555ef04d3da..1583ef5fecf 100644 --- a/spec/lib/pretty_text_spec.rb +++ b/spec/lib/pretty_text_spec.rb @@ -2681,4 +2681,16 @@ HTML expect(cooked.strip).to eq(html.strip) end + + it "handles deprecations correctly" do + Rails + .logger + .expects(:warn) + .once + .with("[PrettyText] Deprecation notice: Some deprecation message") + + PrettyText.v8.eval <<~JS + require("discourse-common/lib/deprecated").default("Some deprecation message"); + JS + end end