user-select-contain-polyfill
user-select-contain-polyfill copied to clipboard
Am I misunderstanding something, or can this not be polyfilled to work as intended by the standard?
I assumed that user-select: contain would mimic the selection behaviour of e.g. a textarea. That is, if you select all, it only selects the content of that element. I made that assumption based on the fact that user-select: auto means contain on editable elements. Hence I assumed that the behaviour observed there, is the behaviour for contain on non-editable elements too.
I used this polyfill on a pre tag, selected some text inside it, and hit CtrlA and it selected the entire document, instead of the content of the pre. Now there are four possible scenario's AFAIK:
- I did something wrong in the test, and this is supposed to work.
- My interpretation of the intended standard behaviour is wrong.
- It's a bug in this polyfill that can be fixed.
- The behaviour is not up to standards, but cannot currently be polyfilled due to technical limitations.
Can someone explain which one it is?
section {
user-select: none;
}
/* hack 禁止跨元素选择 */
section:hover {
user-select: text;
}
this work for me
Sorry, but that's neither an answer to the question I posed, nor a solution to any related issue. That's an unrelated workaround that might replace this polyfill in some highly specific cases. For example in our case that wouldn't work at all, because the element will not be hovered. Please be aware that I'm asking a question about the functionality of this polyfill, I'm looking for an answer, not a solution or a workaround.