W3C home > Mailing lists > Public > public-webapps@w3.org > April to June 2012

Proposal: Document.parse() [AKA: Implied Context Parsing]

From: Rafael Weinstein <rafaelw@google.com>
Date: Fri, 25 May 2012 00:01:43 -0700
Message-ID: <CABMdHiR2NKh+Dc0yF5A+5Qq8G1Z6DQ6pg0V8kJsZESrwgeY=Zg@mail.gmail.com>
To: Webapps WG <public-webapps@w3.org>
Ok, so from consensus on earlier threads, here's the full API & semantics.

Now's the time to raise objections to UA's adding support for this feature.

-----

1) The Document interface is extended to include a new method:

DocumentFragment parse (DOMString markup);

which:
-Invokes the fragment parsing algorithm with markup and an empty
context element,
-Unmarks all scripts in the returned fragment node as "already started"
-Returns the fragment node

2) The fragment parsing algorithm's context element is now optional.

It's behavior is similar to the case of a known context element, but
the tokenizer is simply set to the data state

3) Resetting the insertion appropriately now sets the mode to "Implied
Context" if parsing a fragment and no context element is set, and
aborts.

4) A new "Implied Context" insertion mode is defined which

-Ignores doctype, end tag tokens
-Handles comment & character tokens as if "in body"
-Handles the following start tags as if "in body" (which is as if "in
head"): <style>, <script>, <link>, <meta>
-Handles any other start tag by selecting a context element, resetting
the insertion mode appropriately and reprocessing the token.

5) A new "selecting a context element" algorithm is defined which
takes a start tag as input and outputs an element. The element's
identity is as follows:

-If start tag is tbody, thead, tfoot, caption or colgroup
  return <table>
-if start tag is tr,
  return <tbody>
-if start tag is col
  return <colgroup>
-if start tag is td or td
  return <tr>
-if start tag is head or body
  return <html>
-if start tag is rp or rt
  return <ruby>

-if start tag is a defined SVG localName (case insensitive)
  return <svg>

-if start tag is a defined MathML localName (case insensitive)
  return <math>

-otherwise, return <body>
Received on Friday, 25 May 2012 07:02:17 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 18:49:52 GMT