<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>17089</bug_id>
          
          <creation_ts>2012-05-17 14:13:58 +0000</creation_ts>
          <short_desc>[Shadow]: activeElement adjustment adjusts activeElement to the shadow root itself</short_desc>
          <delta_ts>2015-07-06 08:07:33 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebAppsWG</product>
          <component>HISTORICAL - Component Model</component>
          <version>unspecified</version>
          <rep_platform>PC</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>MOVED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Dominic Cooney">dominicc</reporter>
          <assigned_to name="Dimitri Glazkov">dglazkov</assigned_to>
          
          
          <qa_contact>public-webapps-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>67807</commentid>
    <comment_count>0</comment_count>
    <who name="Dominic Cooney">dominicc</who>
    <bug_when>2012-05-17 14:13:58 +0000</bug_when>
    <thetext>Given this situation:

&lt;div id=&quot;d&quot;&gt;
+ {SR}
  +&lt;input id=&quot;i&quot;&gt;

and the input has focus, then intuitively the document.activeElement should be #d and the ShadowRoot.activeElement should be #i.

To do this adjustment, Section 8.3 says:

Run the retargeting algorithm with ELEMENT (ie #i) as input

The retargeting algorithm says:

Input
  NODE, a DOM node
Output
  TARGETS, a list of tuples, each containing NODE&apos;s ancestor and its relative target

[So NODE=#i]

Let BOUNDARY be a flag, initialized to false
[NODE=#i, BOUNDARY=false]
Let STACK be a stack of DOM nodes
[NODE=#i, BOUNDARY=false, STACK=[]]
Let ANCESTOR be NODE
[NODE=#i, ANCESTOR=#i, BOUNDARY=false,STACK=[]]
Repeat while ANCESTOR exists: {
[it exists]
  If ANCESTOR is a shadow root, set BOUNDARY to true
[ANCESTOR=#i is not a shadow root]
  If ANCESTOR is as an insertion point, push ANCESTOR into STACK
[ANCESTOR=#i is not an insertion point]
  If BOUNDARY is set to true {
[BOUNDARY=false is not set to true, so skip]
    Pop STACK if STACK is not empty
    Set BOUNDARY to false state
  If STACK is empty, push ANCESTOR into STACK
[NODE=#i, ANCESTOR=#i, BOUNDARY=false, STACK=[#i]]
  Let TARGET be the DOM node at the top of STACK
[TARGET=#i, NODE=#i, ANCESTOR=#i, BOUNDARY=false, STACK=[#i]]
  Add (TARGET, ANCESTOR) tuple to TARGETS
[TARGET=#i, NODE=#i, ANCESTOR=#i, BOUNDARY=false, STACK=[#i], TARGETS={(#i, #i)}]
  Set ANCESTOR to be the result of parent calculation algorithm, given ANCESTOR as input
[Since #i is not a shadow root, and not distributed to an insertion point, ANCESTOR=SR per the parent calculation algorithm]

The second iteration of the loop:

[TARGET=#i, NODE=#i, ANCESTOR=SR, BOUNDARY=false, STACK=[#i], TARGETS={(#i, #i)}]
If ANCESTOR is a shadow root, set BOUNDARY to true
[TARGET=#i, NODE=#i, ANCESTOR=SR, BOUNDARY=true, STACK=[#i], TARGETS={(#i, #i)}]
If ANCESTOR is as an insertion point, push ANCESTOR into STACK
[No]
If BOUNDARY is set to true {
[Yes]
  Pop STACK if STACK is not empty
[TARGET=#i, NODE=#i, ANCESTOR=SR, BOUNDARY=true, STACK=[], TARGETS={(#i, #i)}]
  Set BOUNDARY to false state
[TARGET=#i, NODE=#i, ANCESTOR=SR, BOUNDARY=false, STACK=[], TARGETS={(#i, #i)}]
}
If STACK is empty, push ANCESTOR into STACK
[TARGET=#i, NODE=#i, ANCESTOR=SR, BOUNDARY=false, STACK=[SR], TARGETS={(#i, #i)}]
Let TARGET be the DOM node at the top of STACK
[TARGET=SR, NODE=#i, ANCESTOR=SR, BOUNDARY=false, STACK=[SR], TARGETS={(#i, #i)}]
Add (TARGET, ANCESTOR) tuple to TARGETS
[TARGET=SR, NODE=#i, ANCESTOR=SR, BOUNDARY=false, STACK=[SR], TARGETS={(#i, #i), (SR, SR)}]
… (algorithm continues) …

Note that we are off the rails at this point by pushing (SR, SR) to TARGETS, because Section 8.3 continues:

For each TUPLE in the resulting list of tuples:
Let ADJUSTED be the first value of the TUPLE
Let NODE be the second value of the TUPLE
If NODE is a Document or a shadow root, set the value of the activeElement to ADJUSTED.

This means that the ShadowRoot.activeElement is set to the ShadowRoot, and hence information about the active element (ie #i) is lost. This is contrary to the goal of section 8.3, &quot;To prevent loss of information when adjusting this value, each shadow root must also have an activeElement property to store the value of the focused element in the shadow DOM subtree.&quot;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>121665</commentid>
    <comment_count>1</comment_count>
    <who name="Hayato Ito">hayato</who>
    <bug_when>2015-07-06 08:07:33 +0000</bug_when>
    <thetext>Moved to https://github.com/w3c/webcomponents/issues/251</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>