[html5] r5700 - [e] (0) Clarify the way bidi interacts with alert() Fixing http://www.w3.org/Bug [...]

whatwg at whatwg.org whatwg at whatwg.org
Fri Dec 3 15:54:21 PST 2010


Author: ianh
Date: 2010-12-03 15:54:20 -0800 (Fri, 03 Dec 2010)
New Revision: 5700

Modified:
   complete.html
   index
   source
Log:
[e] (0) Clarify the way bidi interacts with alert()
Fixing http://www.w3.org/Bugs/Public/show_bug.cgi?id=10827

Modified: complete.html
===================================================================
--- complete.html	2010-12-02 07:15:33 UTC (rev 5699)
+++ complete.html	2010-12-03 23:54:20 UTC (rev 5700)
@@ -214,7 +214,7 @@
 
   <header class=head id=head><p><a class=logo href=http://www.whatwg.org/ rel=home><img alt=WHATWG height=101 src=/images/logo width=101></a></p>
    <hgroup><h1>Web Applications 1.0</h1>
-    <h2 class="no-num no-toc">Draft Standard — 2 December 2010</h2>
+    <h2 class="no-num no-toc">Draft Standard — 3 December 2010</h2>
    </hgroup><p>You can take part in this work. <a href=http://www.whatwg.org/mailing-list>Join the working group's discussion list.</a></p>
    <p><strong>Web designers!</strong> We have a <a href=http://blog.whatwg.org/faq/>FAQ</a>, a <a href=http://forums.whatwg.org/>forum</a>, and a <a href=http://www.whatwg.org/mailing-list#help>help mailing list</a> for you!</p>
    <!--<p class="impl"><strong>Implementors!</strong> We have a <a href="http://www.whatwg.org/mailing-list#implementors">mailing list</a> for you too!</p>-->
@@ -87163,8 +87163,15 @@
   as an independent set of one or more bidirectional algorithm
   paragraphs when displayed, as defined by the bidirectional
   algorithm, including, for instance, supporting the
-  paragraph-breaking behaviour of U+000A LINE FEED (LF) characters. <a href=#refsBIDI>[BIDI]</a></p>
+  paragraph-breaking behaviour of U+000A LINE FEED (LF) characters.
+  For the purposes of determining the paragraph level of such text in
+  the bidirectional algorithm, this specification does <em>not</em>
+  provide a higher-level override of rules P2 and P3. <a href=#refsBIDI>[BIDI]</a></p>
 
+  <p>When necessary, authors can enforce a particular direction for a
+  given paragraph by starting it with the Unicode U+200E LEFT-TO-RIGHT
+  MARK or U+200F RIGHT-TO-LEFT MARK characters.</p>
+
   <div class=example>
 
    <p>Thus, the following script:</p>
@@ -87183,7 +87190,8 @@
 
    <p>For a more complex example, consider the following script:</p>
 
-   <pre>var s;
+   <pre class=bad>/* Warning: this script does not handle right-to-left scripts correctly */
+var s;
 if (s = prompt('What is your name?')) {
   alert(s + '! Ok, Fred, ' + s + ', and Wilma will get the car.');
 }</pre>
@@ -87192,16 +87200,22 @@
    alert "<samp>Kitty! Ok, Fred, Kitty, and Wilma will get the
    car.</samp>". However, if the user enters "<kbd dir=rtl lang=ar>لا أفهم</kbd>",
    then the bidirectional algorithm will determine that the direction
-   of the paragraph is right-to-left, and so the output will be "<samp lang=""><bdo dir=rtl>لا أفهم! derF ,kO, لا أفهم, rac eht teg lliw amliW dna.</bdo></samp>"!</p>
+   of the paragraph is right-to-left, and so the output will be the
+   following unintended mess: "<samp lang=""><bdo dir=rtl>لا أفهم! derF ,kO, لا أفهم, rac eht teg lliw amliW dna.</bdo></samp>"</p>
 
+   <p>To force an alert that starts with user-provided text (or other
+   text of unknown directionality) to render left-to-right, the string
+   can be prefixed with a U+200E LEFT-TO-RIGHT MARK character:</p>
+
+   <pre>var s;
+if (s = prompt('What is your name?')) {
+  alert('<strong>\u200E</strong>' + s + '! Ok, Fred, ' + s + ', and Wilma will get the car.');
+}</pre>
+
   </div>
 
-  <p>When necessary, authors can enforce a particular direction for a
-  given paragraph by starting it with the Unicode U+200E LEFT-TO-RIGHT
-  MARK or U+200F RIGHT-TO-LEFT MARK characters.</p>
 
 
-
   <h3 id=print-media><span class=secno>14.7 </span>Print media</h3>
 
   <p>User agents are expected to allow the user to request the

Modified: index
===================================================================
--- index	2010-12-02 07:15:33 UTC (rev 5699)
+++ index	2010-12-03 23:54:20 UTC (rev 5700)
@@ -218,7 +218,7 @@
 
   <header class=head id=head><p><a class=logo href=http://www.whatwg.org/ rel=home><img alt=WHATWG height=101 src=/images/logo width=101></a></p>
    <hgroup><h1>HTML5 (including next generation additions still in development)</h1>
-    <h2 class="no-num no-toc">Draft Standard — 2 December 2010</h2>
+    <h2 class="no-num no-toc">Draft Standard — 3 December 2010</h2>
    </hgroup><p>You can take part in this work. <a href=http://www.whatwg.org/mailing-list>Join the working group's discussion list.</a></p>
    <p><strong>Web designers!</strong> We have a <a href=http://blog.whatwg.org/faq/>FAQ</a>, a <a href=http://forums.whatwg.org/>forum</a>, and a <a href=http://www.whatwg.org/mailing-list#help>help mailing list</a> for you!</p>
    <!--<p class="impl"><strong>Implementors!</strong> We have a <a href="http://www.whatwg.org/mailing-list#implementors">mailing list</a> for you too!</p>-->
@@ -83076,8 +83076,15 @@
   as an independent set of one or more bidirectional algorithm
   paragraphs when displayed, as defined by the bidirectional
   algorithm, including, for instance, supporting the
-  paragraph-breaking behaviour of U+000A LINE FEED (LF) characters. <a href=#refsBIDI>[BIDI]</a></p>
+  paragraph-breaking behaviour of U+000A LINE FEED (LF) characters.
+  For the purposes of determining the paragraph level of such text in
+  the bidirectional algorithm, this specification does <em>not</em>
+  provide a higher-level override of rules P2 and P3. <a href=#refsBIDI>[BIDI]</a></p>
 
+  <p>When necessary, authors can enforce a particular direction for a
+  given paragraph by starting it with the Unicode U+200E LEFT-TO-RIGHT
+  MARK or U+200F RIGHT-TO-LEFT MARK characters.</p>
+
   <div class=example>
 
    <p>Thus, the following script:</p>
@@ -83096,7 +83103,8 @@
 
    <p>For a more complex example, consider the following script:</p>
 
-   <pre>var s;
+   <pre class=bad>/* Warning: this script does not handle right-to-left scripts correctly */
+var s;
 if (s = prompt('What is your name?')) {
   alert(s + '! Ok, Fred, ' + s + ', and Wilma will get the car.');
 }</pre>
@@ -83105,16 +83113,22 @@
    alert "<samp>Kitty! Ok, Fred, Kitty, and Wilma will get the
    car.</samp>". However, if the user enters "<kbd dir=rtl lang=ar>لا أفهم</kbd>",
    then the bidirectional algorithm will determine that the direction
-   of the paragraph is right-to-left, and so the output will be "<samp lang=""><bdo dir=rtl>لا أفهم! derF ,kO, لا أفهم, rac eht teg lliw amliW dna.</bdo></samp>"!</p>
+   of the paragraph is right-to-left, and so the output will be the
+   following unintended mess: "<samp lang=""><bdo dir=rtl>لا أفهم! derF ,kO, لا أفهم, rac eht teg lliw amliW dna.</bdo></samp>"</p>
 
+   <p>To force an alert that starts with user-provided text (or other
+   text of unknown directionality) to render left-to-right, the string
+   can be prefixed with a U+200E LEFT-TO-RIGHT MARK character:</p>
+
+   <pre>var s;
+if (s = prompt('What is your name?')) {
+  alert('<strong>\u200E</strong>' + s + '! Ok, Fred, ' + s + ', and Wilma will get the car.');
+}</pre>
+
   </div>
 
-  <p>When necessary, authors can enforce a particular direction for a
-  given paragraph by starting it with the Unicode U+200E LEFT-TO-RIGHT
-  MARK or U+200F RIGHT-TO-LEFT MARK characters.</p>
 
 
-
   <h3 id=print-media><span class=secno>12.7 </span>Print media</h3>
 
   <p>User agents are expected to allow the user to request the

Modified: source
===================================================================
--- source	2010-12-02 07:15:33 UTC (rev 5699)
+++ source	2010-12-03 23:54:20 UTC (rev 5700)
@@ -99902,9 +99902,16 @@
   as an independent set of one or more bidirectional algorithm
   paragraphs when displayed, as defined by the bidirectional
   algorithm, including, for instance, supporting the
-  paragraph-breaking behaviour of U+000A LINE FEED (LF) characters. <a
+  paragraph-breaking behaviour of U+000A LINE FEED (LF) characters.
+  For the purposes of determining the paragraph level of such text in
+  the bidirectional algorithm, this specification does <em>not</em>
+  provide a higher-level override of rules P2 and P3. <a
   href="#refsBIDI">[BIDI]</a></p>
 
+  <p>When necessary, authors can enforce a particular direction for a
+  given paragraph by starting it with the Unicode U+200E LEFT-TO-RIGHT
+  MARK or U+200F RIGHT-TO-LEFT MARK characters.</p>
+
   <div class="example">
 
    <p>Thus, the following script:</p>
@@ -99923,7 +99930,8 @@
 
    <p>For a more complex example, consider the following script:</p>
 
-   <pre>var s;
+   <pre class="bad">/* Warning: this script does not handle right-to-left scripts correctly */
+var s;
 if (s = prompt('What is your name?')) {
   alert(s + '! Ok, Fred, ' + s + ', and Wilma will get the car.');
 }</pre>
@@ -99933,18 +99941,23 @@
    car.</samp>". However, if the user enters "<kbd dir="rtl"
    lang="ar">&#x644;&#x627; &#x623;&#x641;&#x647;&#x645;</kbd>",
    then the bidirectional algorithm will determine that the direction
-   of the paragraph is right-to-left, and so the output will be "<samp
-   lang=""><bdo
-   dir="rtl">&#x644;&#x627; &#x623;&#x641;&#x647;&#x645;! derF ,kO, &#x644;&#x627; &#x623;&#x641;&#x647;&#x645;, rac eht teg lliw amliW dna.</bdo></samp>"!</p>
+   of the paragraph is right-to-left, and so the output will be the
+   following unintended mess: "<samp lang=""><bdo
+   dir="rtl">&#x644;&#x627; &#x623;&#x641;&#x647;&#x645;! derF ,kO, &#x644;&#x627; &#x623;&#x641;&#x647;&#x645;, rac eht teg lliw amliW dna.</bdo></samp>"</p>
 
+   <p>To force an alert that starts with user-provided text (or other
+   text of unknown directionality) to render left-to-right, the string
+   can be prefixed with a U+200E LEFT-TO-RIGHT MARK character:</p>
+
+   <pre>var s;
+if (s = prompt('What is your name?')) {
+  alert('<strong>\u200E</strong>' + s + '! Ok, Fred, ' + s + ', and Wilma will get the car.');
+}</pre>
+
   </div>
 
-  <p>When necessary, authors can enforce a particular direction for a
-  given paragraph by starting it with the Unicode U+200E LEFT-TO-RIGHT
-  MARK or U+200F RIGHT-TO-LEFT MARK characters.</p>
 
 
-
   <h3>Print media</h3>
 
   <p>User agents are expected to allow the user to request the




More information about the Commit-Watchers mailing list