Commit 7fd8b032 authored by Emilio Cobos Álvarez's avatar Emilio Cobos Álvarez
Browse files

Bug 1505213 - Allow ::slotted()::placeholder. r=heycam

Differential Revision: https://phabricator.services.mozilla.com/D11132

--HG--
extra : moz-landing-system : lando
parent c76f4745
Loading
Loading
Loading
Loading
+9 −5
Original line number Diff line number Diff line
@@ -27,12 +27,16 @@ include!(concat!(
impl ::selectors::parser::PseudoElement for PseudoElement {
    type Impl = SelectorImpl;

    // ::slotted() should support all tree-abiding pseudo-elements, see
    // https://drafts.csswg.org/css-scoping/#slotted-pseudo
    // https://drafts.csswg.org/css-pseudo-4/#treelike
    fn valid_after_slotted(&self) -> bool {
        // TODO(emilio): Remove this function or this comment after [1] is
        // resolved.
        //
        // [1]: https://github.com/w3c/csswg-drafts/issues/3150
        self.is_before_or_after()
        matches!(
            *self,
            PseudoElement::Before |
            PseudoElement::After |
            PseudoElement::Placeholder
        )
    }

    fn supports_pseudo_class(&self, pseudo_class: &NonTSPseudoClass) -> bool {
+4 −0
Original line number Diff line number Diff line
[slotted-parsing.html]
  [Should be a valid selector: '::slotted(*)::marker']
    expected: FAIL
+2 −0
Original line number Diff line number Diff line
@@ -49,6 +49,8 @@
  // Allow tree-abiding pseudo elements after ::slotted
  test_valid_selector("::slotted(*)::before");
  test_valid_selector("::slotted(*)::after");
  test_valid_selector("::slotted(*)::placeholder");
  test_valid_selector("::slotted(*)::marker");

  // Other pseudo elements not valid after ::slotted
  test_invalid_selector("::slotted(*)::first-line");
+6 −0
Original line number Diff line number Diff line
<!doctype html>
<style>
  ::placeholder { color: green }
</style>
<input placeholder="I should be green">
<textarea placeholder="I should be green"></textarea>
+19 −0
Original line number Diff line number Diff line
<!doctype html>
<meta charset="utf-8">
<title>CSS Scoping Test: ::slotted() allows ::placeholder</title>
<link rel="author" title="Emilio Cobos Álvarez" href="mailto:emilio@crisal.io">
<link rel="author" title="Mozilla" href="https://mozilla.org">
<link rel="help" href="https://drafts.csswg.org/css-scoping/#slotted-pseudo">
<link rel="match" href="slotted-placeholder-ref.html">
<div id="host">
  <input placeholder="I should be green">
  <textarea placeholder="I should be green"></textarea>
</div>
<script>
  host.attachShadow({ mode: "open" }).innerHTML = `
    <style>
      ::slotted(*)::placeholder { color: green }
    </style>
    <slot></slot>
  `;
</script>