Open Bug 365900 Opened 14 years ago Updated 5 years ago

wrong focusNode/anchorNode for focused elements inside table

Categories

(Core :: DOM: Selection, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

UNCONFIRMED

People

(Reporter: surkov, Unassigned)

Details

Attachments

(1 file)

Attached file testcase
If focusable element is placed inside html:table and the element becomes focused then window.getSelection().focusNode/anchorNode returns either row or cell of table. focusNode/anchorNode should return focused element.
This sounds a lot like bug 336936.
Assignee: selection → nobody
QA Contact: selection
I have encountered this bug, and found that it occurs when <body contenteditable="true"> and the table cell contains an empty element that has an attribute declared, i.e. occurs for <td><span style="text-align:center;"></span></td> not <td><span></span></td>.  Tested on 43.0.4 on Mac OSX Yosemite.

Sample HTML to recreate the issue:

<!doctype html>
<html>
<head>
	<title>Firefox Seleciton Bug</title>
	<style>
		table {
			width:75%;
			margin: 10px auto; 
			border: 1px solid #ccc
		}
		td {
			border: 1px solid #ccc;
			width: 50%;
		}
	</style>
</head>
<body contenteditable="true">
	<h1>Firefox Selection Bug</h1>
	<table>
		<tr>
			<td><span style="text-align:center;"></span></td>
			<td><span style="text-align:center;">contented</span></td>
		</tr>	
	</table>
	<script>
		var tds = document.querySelectorAll('td');
		for (var i = 0; i < tds.length; i++) {
			tds[i].addEventListener('click', function(){
				console.log(window.getSelection());
			});
		}
	</script>
</body>
</html>
You need to log in before you can comment on or make changes to this bug.