Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(153)

Unified Diff: Source/bindings/core/v8/V8EventListener.cpp

Issue 1076783002: Support non-function object values assigned to EventHandler attributes (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: drop (now) pointless assert Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/bindings/core/v8/V8EventListener.cpp
diff --git a/Source/bindings/core/v8/V8EventListener.cpp b/Source/bindings/core/v8/V8EventListener.cpp
index 52872e3189e71b7ddf994a7daf40102e5510200d..19b38366b2013bdcfb8edcb6f0c786523dcf3fe6 100644
--- a/Source/bindings/core/v8/V8EventListener.cpp
+++ b/Source/bindings/core/v8/V8EventListener.cpp
@@ -55,8 +55,14 @@ v8::Local<v8::Function> V8EventListener::getListenerFunction(ScriptState* script
if (listener->IsFunction())
return v8::Local<v8::Function>::Cast(listener);
+ // The EventHandler callback function type (used for event handler
+ // attributes in HTML) has [TreatNonObjectAsNull], which implies that
+ // non-function objects should be treated as no-op functions that return
+ // undefined.
+ if (isAttribute())
+ return v8::Local<v8::Function>();
+
if (listener->IsObject()) {
- ASSERT_WITH_MESSAGE(!isAttribute(), "EventHandler attributes should only accept JS Functions as input.");
v8::Local<v8::Value> property = listener->Get(v8AtomicString(isolate(), "handleEvent"));
// Check that no exceptions were thrown when getting the
// handleEvent property and that the value is a function.
« no previous file with comments | « LayoutTests/fast/html/eventhandler-attribute-non-callable-expected.txt ('k') | Source/bindings/core/v8/V8EventListenerList.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698