Last Comment Bug 561664 - document.activeElement should never return native anonymous content
: document.activeElement should never return native anonymous content
Product: Core
Classification: Components
Component: DOM: Core & HTML (show other bugs)
: Trunk
: x86 Mac OS X
: -- normal (vote)
: ---
Assigned To: Olli Pettay [:smaug]
: Andrew Overholt [:overholt]
Depends on:
  Show dependency treegraph
Reported: 2010-04-25 14:08 PDT by Olli Pettay [:smaug]
Modified: 2012-05-04 09:27 PDT (History)
4 users (show)
See Also:
Crash Signature:
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---

patch (2.06 KB, patch)
2012-05-03 13:17 PDT, Olli Pettay [:smaug]
enndeakin: review+
Details | Diff | Splinter Review
+fix to test_bug430351.html (5.00 KB, patch)
2012-05-04 04:19 PDT, Olli Pettay [:smaug]
enndeakin: review+
Details | Diff | Splinter Review

Description Olli Pettay [:smaug] 2010-04-25 14:08:10 PDT
Currently document.activeElement may return the input element inside type="file". 
Content JS gets then an exception when it tries to access the element.
Comment 2 Scott González 2012-05-03 07:13:55 PDT
This is causing problems for us in jQuery UI. We wrap elements for certain animations, and the wrapping causes elements to lose focus, so we reset focus after wrapping. However, if a file input has focus, then we try setting the focus on the exposed text input, which is no longer in the document (not sure why).

jQuery UI bug:
Reduced test case using jQuery UI:
Reduced test case using plain JavaScript/DOM:
Comment 3 Olli Pettay [:smaug] 2012-05-03 13:17:27 PDT
Created attachment 620830 [details] [diff] [review]
Comment 4 Olli Pettay [:smaug] 2012-05-03 13:18:04 PDT
Comment on attachment 620830 [details] [diff] [review]
Comment 5 Olli Pettay [:smaug] 2012-05-03 15:49:42 PDT
Bah, the patch revealed another bug.
Comment 6 Olli Pettay [:smaug] 2012-05-04 04:19:46 PDT
Created attachment 621005 [details] [diff] [review]
+fix to test_bug430351.html
Comment 7 Olli Pettay [:smaug] 2012-05-04 04:51:06 PDT
Neil, the patch doesn't change the focusing behavior, but it is just that
test_bug430351.html tests currently  the_native_anon_button_inside_file_input != <input type="file">
With the patch that becomes <input type="file"> != <input type="file">
Comment 8 Olli Pettay [:smaug] 2012-05-04 09:27:31 PDT

Note You need to log in before you can comment on or make changes to this bug.