diff --git a/Libraries/LibWeb/Bindings/HTMLCanvasElementWrapper.cpp b/Libraries/LibWeb/Bindings/HTMLCanvasElementWrapper.cpp index 8479601ad6..8f586aa0ed 100644 --- a/Libraries/LibWeb/Bindings/HTMLCanvasElementWrapper.cpp +++ b/Libraries/LibWeb/Bindings/HTMLCanvasElementWrapper.cpp @@ -74,15 +74,13 @@ JS::Value HTMLCanvasElementWrapper::get_context(JS::Interpreter& interpreter) auto* impl = impl_from(interpreter); if (!impl) return {}; - auto& arguments = interpreter.call_frame().arguments; - if (arguments.size() >= 1) { - auto string = arguments[0].to_string(interpreter); - if (interpreter.exception()) - return {}; - auto* context = impl->get_context(string); - return wrap(interpreter.heap(), *context); - } - return JS::js_undefined(); + auto context_type = interpreter.call_frame().arguments[0].to_string(interpreter); + if (interpreter.exception()) + return {}; + if (context_type != "2d") + return JS::js_null(); + auto* context = impl->get_context(context_type); + return wrap(interpreter.heap(), *context); } JS::Value HTMLCanvasElementWrapper::width_getter(JS::Interpreter& interpreter) diff --git a/Libraries/LibWeb/DOM/HTMLCanvasElement.cpp b/Libraries/LibWeb/DOM/HTMLCanvasElement.cpp index a37139c6fe..b2fd8b4389 100644 --- a/Libraries/LibWeb/DOM/HTMLCanvasElement.cpp +++ b/Libraries/LibWeb/DOM/HTMLCanvasElement.cpp @@ -76,7 +76,7 @@ RefPtr HTMLCanvasElement::create_layout_node(const StyleProperties* CanvasRenderingContext2D* HTMLCanvasElement::get_context(String type) { - ASSERT(type.to_lowercase() == "2d"); + ASSERT(type == "2d"); if (!m_context) m_context = CanvasRenderingContext2D::create(*this); return m_context;