MSEdgeExplainers icon indicating copy to clipboard operation
MSEdgeExplainers copied to clipboard

[CSS Anchored Positioning] Does the `anchor` IDL attribute reflect to the content attribute?

Open mfreed7 opened this issue 4 years ago • 2 comments

The anchor positioning proposal contains this proposed syntax:

document.getElementById('myPopup').anchor = document.getElementById('myButton');

Quick question: when you execute that line on <popup id=myPopup>, do you get <popup id=myPopup anchor=myButton>? What if you instead assign anchor to document.createElement('button'), which doesn't have an id?

mfreed7 avatar Jun 16 '21 23:06 mfreed7

Hmm, maybe we should just change the syntax to Element.setAttribute('anchor', 'someIdHere'); and the usual behavior + processing of IDREFs occurs. WDYT, @BoCupp-Microsoft?

melanierichards avatar Jun 17 '21 16:06 melanierichards

Hmm, maybe we should just change the syntax to Element.setAttribute('anchor', 'someIdHere'); and the usual behavior + processing of IDREFs occurs. WDYT, @BoCupp-Microsoft?

I like that approach. It cuts off a number of potential issues. Like another one I just thought of:

const myButton = document.getElementById('myButton');
const myPopup = document.getElementById('myPopup');
myPopup.anchor = myButton;
myButton.id = 'something-else';
myPopup.getAttribute('anchor'); // myButton? something-else?
myPopup.anchor; // null? still myButton?

mfreed7 avatar Jun 18 '21 23:06 mfreed7