Coder Social home page Coder Social logo

:dir() support about soupsieve HOT 2 CLOSED

facelessuser avatar facelessuser commented on August 16, 2024
:dir() support

from soupsieve.

Comments (2)

facelessuser avatar facelessuser commented on August 16, 2024

Reading the HTML5 spec, below is my current understanding. I am confused by [detect 2].

Is ltr

  • Check dir attribute is in ltr state.
  • If document element and dir is not defined or invalid.
  • input element and in telephone state and dir is not in a defined or invalid.

Is rtl

  • dir is set to rtl

Detect 1

  • If input type of text, search, telephone, URL, or email and set to auto.
  • If element is a textarea and the dir attribute is in the auto state.

Check value for first character that is of bidirectioal AL or R with no bidi type of L before it. Then it is rtl

If element value is not empty string or it is the document element, then it is ltr.

Otherwise, directionality is inherited by parent.

Detect 2

  • Element's dir is set to auto
  • Element is a bdi element with no valid dir.

Check that text node is a descendant of the element, but does not have an ancestor element that is a descendant of the element (so direct child node?). Check first character that has bidi type of L, AL, or R, if found. Or if document element, it's ltr. Lastly, just inherit.

This is hard to understand. There appears to be some additional stipulations, but man is this poorly written:

The character is not in a Text node that has an ancestor element that is
a descendant of the element whose directionality is being determined and
that is either:

  • A bdi element.
  • A script element.
  • A style element.
  • A textarea element.
  • An element with a dir attribute in a defined state.

Inherit

  • Element has a parent and the dir attribute is not in a defined state.

Inherit parent (document element is assumed ltr).

from soupsieve.

facelessuser avatar facelessuser commented on August 16, 2024

Alright, the part I was confused about makes sense now. In detect 2, the next node cannot be in a descendant that is a bdi, script, style, textarea, or an element with a defined dir attribute state. This is doable, complicated, but doable. I think I have most of it coded up now.

EDIT: For HTML only right now.

from soupsieve.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.