Changeset 195681 in webkit


Ignore:
Timestamp:
Jan 27, 2016 12:08:52 PM (8 years ago)
Author:
rniwa@webkit.org
Message:

Rename HTMLSlotElement.getDistributedNodes to getAssignedNodes
https://bugs.webkit.org/show_bug.cgi?id=153534

Reviewed by Antti Koivisto.

Source/WebCore:

Did the rename.

  • html/HTMLSlotElement.idl:

LayoutTests:

Updated the tests to refect the rename. Also added test cases after r192763
to assert we don't assign comment and processing instruction nodes to a slot.

  • fast/shadow-dom/HTMLSlotElement-interface-expected.txt:
  • fast/shadow-dom/HTMLSlotElement-interface.html:
  • fast/shadow-dom/NonDocumentTypeChildNode-interface-assignedSlot.html:
Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r195678 r195681  
     12016-01-26  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Rename HTMLSlotElement.getDistributedNodes to getAssignedNodes
     4        https://bugs.webkit.org/show_bug.cgi?id=153534
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Updated the tests to refect the rename. Also added test cases after r192763
     9        to assert we don't assign comment and processing instruction nodes to a slot.
     10
     11        * fast/shadow-dom/HTMLSlotElement-interface-expected.txt:
     12        * fast/shadow-dom/HTMLSlotElement-interface.html:
     13        * fast/shadow-dom/NonDocumentTypeChildNode-interface-assignedSlot.html:
     14
    1152016-01-27  Tim Horton  <timothy_horton@apple.com>
    216
  • trunk/LayoutTests/fast/shadow-dom/HTMLSlotElement-interface-expected.txt

    r190323 r195681  
    22PASS HTMLSlotElement must be defined on window
    33PASS "name" attribute on HTMLSlotElement must reflect "name" attribute
    4 PASS getDistributedNodes method on HTMLSlotElement must return the list of distributed nodes
    5 PASS getDistributedNodes must update when slot and name attributes are modified
    6 PASS getDistributedNodes must update when a default slot is introduced dynamically by a slot rename
    7 PASS getDistributedNodes must update when slot elements are inserted or removed
     4PASS getAssignedNodes method on HTMLSlotElement must return the list of distributed nodes
     5PASS getAssignedNodes must update when slot and name attributes are modified
     6PASS getAssignedNodes must update when a default slot is introduced dynamically by a slot rename
     7PASS getAssignedNodes must update when slot elements are inserted or removed
    88
  • trunk/LayoutTests/fast/shadow-dom/HTMLSlotElement-interface.html

    r190323 r195681  
    44<title>Shadow DOM: HTMLSlotElement interface</title>
    55<meta name="author" title="Ryosuke Niwa" href="mailto:rniwa@webkit.org">
    6 <meta name="assert" content="HTMLSlotElement must exist on window with name attribute and getDistributedNodes() method">
     6<meta name="assert" content="HTMLSlotElement must exist on window with name attribute and getAssignedNode() method">
    77<link rel="help" href="https://w3c.github.io/webcomponents/spec/shadow/#the-slot-element">
    88<script src="../../resources/testharness.js"></script>
     
    3636
    3737test(function () {
    38     assert_true('getDistributedNodes' in HTMLSlotElement.prototype, '"getDistributedNodes" method must be defined on HTMLSlotElement.prototype');
     38    assert_true('getAssignedNodes' in HTMLSlotElement.prototype, '"getAssignedNodes" method must be defined on HTMLSlotElement.prototype');
    3939
    4040    var shadowHost = document.createElement('div');
     
    4545    shadowRoot.appendChild(slotElement);
    4646
    47     assert_array_equals(slotElement.getDistributedNodes(), [], 'getDistributedNodes must return an empty array when there are no nodes in the shadow tree');
     47    assert_array_equals(slotElement.getAssignedNodes(), [], 'getAssignedNodes must return an empty array when there are no nodes in the shadow tree');
    4848
    4949    shadowHost.appendChild(child);
    50     assert_array_equals(slotElement.getDistributedNodes(), [child], 'getDistributedNodes on a default slot must return an element without slot element');
     50    assert_array_equals(slotElement.getAssignedNodes(), [child], 'getAssignedNodes on a default slot must return an element without slot element');
    5151
    5252    child.setAttribute('slot', 'foo');
    53     assert_array_equals(slotElement.getDistributedNodes(), [], 'getDistributedNodes on a default slot must not return an element with non-empty slot attribute');
     53    assert_array_equals(slotElement.getAssignedNodes(), [], 'getAssignedNodes on a default slot must not return an element with non-empty slot attribute');
    5454
    5555    child.setAttribute('slot', '');
    56     assert_array_equals(slotElement.getDistributedNodes(), [child], 'getDistributedNodes on a default slot must return an element with empty slot attribute');
     56    assert_array_equals(slotElement.getAssignedNodes(), [child], 'getAssignedNodes on a default slot must return an element with empty slot attribute');
    5757
    5858    slotElement.setAttribute('name', 'bar');
    59     assert_array_equals(slotElement.getDistributedNodes(), [], 'getDistributedNodes on a named slot must not return an element with empty slot attribute');
     59    assert_array_equals(slotElement.getAssignedNodes(), [], 'getAssignedNodes on a named slot must not return an element with empty slot attribute');
    6060
    6161    slotElement.setAttribute('name', '');
    62     assert_array_equals(slotElement.getDistributedNodes(), [child], 'getDistributedNodes on an empty name slot must return an element with empty slot attribute');
     62    assert_array_equals(slotElement.getAssignedNodes(), [child], 'getAssignedNodes on an empty name slot must return an element with empty slot attribute');
    6363
    64 }, 'getDistributedNodes method on HTMLSlotElement must return the list of distributed nodes');
     64}, 'getAssignedNodes method on HTMLSlotElement must return the list of distributed nodes');
    6565
    6666test(function () {
     
    7575    shadowRoot.appendChild(slotElement);
    7676
    77     assert_array_equals(slotElement.getDistributedNodes(), [p, b], 'getDistributedNodes must return the distributed nodes');
     77    assert_array_equals(slotElement.getAssignedNodes(), [p, b], 'getAssignedNodes must return the distributed nodes');
    7878
    7979    slotElement.name = 'foo';
    80     assert_array_equals(slotElement.getDistributedNodes(), [], 'getDistributedNodes must be empty when there are no matching elements for the slot name');
     80    assert_array_equals(slotElement.getAssignedNodes(), [], 'getAssignedNodes must be empty when there are no matching elements for the slot name');
    8181
    8282    b.slot = 'foo';
    83     assert_array_equals(slotElement.getDistributedNodes(), [b], 'getDistributedNodes must return the nodes with the matching slot name');
     83    assert_array_equals(slotElement.getAssignedNodes(), [b], 'getAssignedNodes must return the nodes with the matching slot name');
    8484
    8585    p.slot = 'foo';
    86     assert_array_equals(slotElement.getDistributedNodes(), [p, b], 'getDistributedNodes must return the nodes with the matching slot name in the tree order');
     86    assert_array_equals(slotElement.getAssignedNodes(), [p, b], 'getAssignedNodes must return the nodes with the matching slot name in the tree order');
    8787
    8888    slotElement.name = null;
    89     assert_array_equals(slotElement.getDistributedNodes(), [], 'getDistributedNodes must be empty for a default slot when all elements have "slot" attributes specified');
     89    assert_array_equals(slotElement.getAssignedNodes(), [], 'getAssignedNodes must be empty for a default slot when all elements have "slot" attributes specified');
    9090
    91 }, 'getDistributedNodes must update when slot and name attributes are modified');
     91}, 'getAssignedNodes must update when slot and name attributes are modified');
    9292
    9393test(function () {
     
    101101    shadowRoot.appendChild(slotElement);
    102102
    103     assert_array_equals(slotElement.getDistributedNodes(), [], 'getDistributedNodes must be empty when there are no matching elements for the slot name');
     103    assert_array_equals(slotElement.getAssignedNodes(), [], 'getAssignedNodes must be empty when there are no matching elements for the slot name');
    104104
    105105    slotElement.name = null;
    106     assert_array_equals(slotElement.getDistributedNodes(), [child], 'getDistributedNodes must be empty when there are no matching elements for the slot name');
     106    assert_array_equals(slotElement.getAssignedNodes(), [child], 'getAssignedNodes must be empty when there are no matching elements for the slot name');
    107107
    108 }, 'getDistributedNodes must update when a default slot is introduced dynamically by a slot rename');
     108}, 'getAssignedNodes must update when a default slot is introduced dynamically by a slot rename');
    109109
    110110test(function () {
     
    112112    var p = document.createElement('p');
    113113    var text = document.createTextNode('');
     114    var comment = document.createComment('');
     115    var processingInstruction = document.createProcessingInstruction('target', 'data');
    114116    var b = document.createElement('b');
    115117    shadowHost.appendChild(p);
    116118    shadowHost.appendChild(text);
     119    shadowHost.appendChild(comment);
     120    shadowHost.appendChild(processingInstruction);
    117121    shadowHost.appendChild(b);
    118122
     
    125129    shadowRoot.appendChild(secondSlotElement);
    126130
    127     assert_array_equals(firstSlotElement.getDistributedNodes(), [p, text, b],
    128         'getDistributedNodes on a default slot must return the elements without slot attributes and text nodes');
    129     assert_array_equals(secondSlotElement.getDistributedNodes(), [],
    130         'getDistributedNodes on the second unnamed slot element must return an empty array');
     131    assert_array_equals(firstSlotElement.getAssignedNodes(), [p, text, b],
     132        'getAssignedNodes on a default slot must return the elements without slot attributes and text nodes');
     133    assert_array_equals(secondSlotElement.getAssignedNodes(), [],
     134        'getAssignedNodes on the second unnamed slot element must return an empty array');
    131135
    132136    shadowRoot.removeChild(firstSlotElement);
    133     assert_array_equals(firstSlotElement.getDistributedNodes(), [],
    134         'getDistributedNodes on a detached formerly-default slot must return an empty array');
    135     assert_array_equals(secondSlotElement.getDistributedNodes(), [p, text, b],
    136         'getDistributedNodes on the second unnamed slot element after removing the first must return the elements without slot attributes and text nodes');
     137    assert_array_equals(firstSlotElement.getAssignedNodes(), [],
     138        'getAssignedNodes on a detached formerly-default slot must return an empty array');
     139    assert_array_equals(secondSlotElement.getAssignedNodes(), [p, text, b],
     140        'getAssignedNodes on the second unnamed slot element after removing the first must return the elements without slot attributes and text nodes');
    137141
    138142    shadowRoot.removeChild(secondSlotElement);
    139143    shadowRoot.appendChild(secondSlotElement);
    140     assert_array_equals(firstSlotElement.getDistributedNodes(), [],
    141         'Removing and re-inserting a default slot must not change the result of getDistributedNodes on a detached slot');
    142     assert_array_equals(secondSlotElement.getDistributedNodes(), [p, text, b],
    143         'Removing and re-inserting a default slot must not change the result of getDistributedNodes');
     144    assert_array_equals(firstSlotElement.getAssignedNodes(), [],
     145        'Removing and re-inserting a default slot must not change the result of getAssignedNodes on a detached slot');
     146    assert_array_equals(secondSlotElement.getAssignedNodes(), [p, text, b],
     147        'Removing and re-inserting a default slot must not change the result of getAssignedNodes');
    144148
    145149    shadowRoot.insertBefore(firstSlotElement, secondSlotElement);
    146     assert_array_equals(firstSlotElement.getDistributedNodes(), [p, text, b],
    147         'getDistributedNodes on a newly inserted unnamed slot element must return the elements without slot attributes and text nodes');
    148     assert_array_equals(secondSlotElement.getDistributedNodes(), [],
    149         'getDistributedNodes on formerly-first but now second unnamed slot element must return an empty array');
     150    assert_array_equals(firstSlotElement.getAssignedNodes(), [p, text, b],
     151        'getAssignedNodes on a newly inserted unnamed slot element must return the elements without slot attributes and text nodes');
     152    assert_array_equals(secondSlotElement.getAssignedNodes(), [],
     153        'getAssignedNodes on formerly-first but now second unnamed slot element must return an empty array');
    150154
    151 }, 'getDistributedNodes must update when slot elements are inserted or removed');
     155}, 'getAssignedNodes must update when slot elements are inserted or removed');
    152156
    153157</script>
  • trunk/LayoutTests/fast/shadow-dom/NonDocumentTypeChildNode-interface-assignedSlot.html

    r189950 r195681  
    5959    shadowHost.appendChild(childTextNode);
    6060
    61     var commentNode = document.createTextNode('');
     61    var commentNode = document.createComment('');
    6262    shadowHost.appendChild(commentNode);
     63
     64    var processingInstructionNode = document.createProcessingInstruction('target', 'data');
     65    shadowHost.appendChild(processingInstructionNode);
    6366
    6467    var shadowRoot = shadowHost.attachShadow({mode: 'open'});
     
    6871    assert_equals(childElement.assignedSlot, slot, 'assignedSlot on an element must return the assigned default slot element');
    6972    assert_equals(childTextNode.assignedSlot, slot, 'assignedSlot on a text node must return the assigned default slot element');
    70     assert_equals(commentNode.assignedSlot, slot, 'assignedSlot on a comment node must return the assigned default slot element');
     73    assert_equals(commentNode.assignedSlot, null, 'assignedSlot on a comment node must always return null');
     74    assert_equals(processingInstructionNode.assignedSlot, null, 'assignedSlot on a comment node must always return null');
    7175
    7276    slot.name = 'foo';
     
    7478    assert_equals(childTextNode.assignedSlot, null, 'assignedSlot on a text node must null when the node is unassigned from a slot element');
    7579    assert_equals(commentNode.assignedSlot, null, 'assignedSlot on a text node must null when the node is unassigned from a slot element');
     80    assert_equals(processingInstructionNode.assignedSlot, null, 'assignedSlot on a text node must null when the node is unassigned from a slot element');
    7681
    7782    childElement.slot = 'foo';
     
    8085    slot.name = null;
    8186    assert_equals(childTextNode.assignedSlot, slot, 'assignedSlot on a text node must return the re-assigned slot element');
    82     assert_equals(commentNode.assignedSlot, slot, 'assignedSlot on a comment node must return the re-assigned slot element');
     87    assert_equals(commentNode.assignedSlot, null, 'assignedSlot on a comment node must always return null');
     88    assert_equals(processingInstructionNode.assignedSlot, null, 'assignedSlot on a comment node must always return null');
    8389
    8490}, 'assignedSlot must return the assigned slot');
     
    95101    shadowHost.appendChild(commentNode);
    96102
     103    var processingInstructionNode = document.createProcessingInstruction('target', 'data');
     104    shadowHost.appendChild(processingInstructionNode);
     105
    97106    var shadowRoot = shadowHost.attachShadow({mode: 'closed'});
    98107    var slot = document.createElement('slot');
    99108    shadowRoot.appendChild(slot);
    100109
    101     assert_equals(childElement.assignedSlot, null, 'assignedSlot on an element must return the assigned slot element.');
    102     assert_equals(childTextNode.assignedSlot, null, 'assignedSlot on a text node must return the assigned slot element.');
    103     assert_equals(commentNode.assignedSlot, null, 'assignedSlot on a comment node must return the assigned slot element.');
     110    assert_equals(childElement.assignedSlot, null, 'assignedSlot on an element must return null if the slot is inside a closed shadow tree.');
     111    assert_equals(childTextNode.assignedSlot, null, 'assignedSlot on a text node must return null if the slot is inside a closed shadow tree.');
     112    assert_equals(commentNode.assignedSlot, null, 'assignedSlot on a comment node must always return null.');
     113    assert_equals(processingInstructionNode.assignedSlot, null, 'assignedSlot on a processing instruction must always return null.');
    104114
    105115}, 'assignedSlot must return null when the assigned slot element is inside a closed shadow tree');
  • trunk/Source/WebCore/ChangeLog

    r195678 r195681  
     12016-01-26  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Rename HTMLSlotElement.getDistributedNodes to getAssignedNodes
     4        https://bugs.webkit.org/show_bug.cgi?id=153534
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Did the rename.
     9
     10        * html/HTMLSlotElement.idl:
     11
    1122016-01-27  Tim Horton  <timothy_horton@apple.com>
    213
  • trunk/Source/WebCore/html/HTMLSlotElement.idl

    r190093 r195681  
    3131
    3232    [Reflect] attribute DOMString name;
    33     [ImplementedAs=assignedNodes] sequence<Node> getDistributedNodes();
     33    [ImplementedAs=assignedNodes] sequence<Node> getAssignedNodes();
    3434
    3535};
Note: See TracChangeset for help on using the changeset viewer.