Skip to content

Commit

Permalink
[e] (0) Clarify the way bidi interacts with alert()
Browse files Browse the repository at this point in the history
Fixing http://www.w3.org/Bugs/Public/show_bug.cgi?id=10827

git-svn-id: http://svn.whatwg.org/webapps@5700 340c8d12-0b0e-0410-8428-c7bf67bfef74
  • Loading branch information
Hixie committed Dec 3, 2010
1 parent 20b7193 commit 43dcea7
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 25 deletions.
30 changes: 22 additions & 8 deletions complete.html
Expand Up @@ -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 &mdash; 2 December 2010</h2>
<h2 class="no-num no-toc">Draft Standard &mdash; 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>-->
Expand Down Expand Up @@ -87163,7 +87163,14 @@ <h4 id=text-rendered-in-native-user-interfaces><span class=secno>14.6.4 </span>T
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>

Expand All @@ -87183,7 +87190,8 @@ <h4 id=text-rendered-in-native-user-interfaces><span class=secno>14.6.4 </span>T

<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>
Expand All @@ -87192,13 +87200,19 @@ <h4 id=text-rendered-in-native-user-interfaces><span class=secno>14.6.4 </span>T
alert "<samp>Kitty! Ok, Fred, Kitty, and Wilma will get the
car.</samp>". However, if the user enters "<kbd dir=rtl lang=ar>&#1604;&#1575;&nbsp;&#1571;&#1601;&#1607;&#1605;</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>&#1604;&#1575;&nbsp;&#1571;&#1601;&#1607;&#1605;!&nbsp;derF&nbsp;,kO,&nbsp;&#1604;&#1575;&nbsp;&#1571;&#1601;&#1607;&#1605;,&nbsp;rac&nbsp;eht&nbsp;teg&nbsp;lliw&nbsp;amliW&nbsp;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>&#1604;&#1575;&nbsp;&#1571;&#1601;&#1607;&#1605;!&nbsp;derF&nbsp;,kO,&nbsp;&#1604;&#1575;&nbsp;&#1571;&#1601;&#1607;&#1605;,&nbsp;rac&nbsp;eht&nbsp;teg&nbsp;lliw&nbsp;amliW&nbsp;dna.</bdo></samp>"</p>

</div>
<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>

<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>
<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>



Expand Down
30 changes: 22 additions & 8 deletions index
Expand Up @@ -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 &mdash; 2 December 2010</h2>
<h2 class="no-num no-toc">Draft Standard &mdash; 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>-->
Expand Down Expand Up @@ -83076,7 +83076,14 @@ time[datetime] { binding: <i title="">time</i>; }</pre>
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>

Expand All @@ -83096,7 +83103,8 @@ time[datetime] { binding: <i title="">time</i>; }</pre>

<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>
Expand All @@ -83105,13 +83113,19 @@ if (s = prompt('What is your name?')) {
alert "<samp>Kitty! Ok, Fred, Kitty, and Wilma will get the
car.</samp>". However, if the user enters "<kbd dir=rtl lang=ar>&#1604;&#1575;&nbsp;&#1571;&#1601;&#1607;&#1605;</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>&#1604;&#1575;&nbsp;&#1571;&#1601;&#1607;&#1605;!&nbsp;derF&nbsp;,kO,&nbsp;&#1604;&#1575;&nbsp;&#1571;&#1601;&#1607;&#1605;,&nbsp;rac&nbsp;eht&nbsp;teg&nbsp;lliw&nbsp;amliW&nbsp;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>&#1604;&#1575;&nbsp;&#1571;&#1601;&#1607;&#1605;!&nbsp;derF&nbsp;,kO,&nbsp;&#1604;&#1575;&nbsp;&#1571;&#1601;&#1607;&#1605;,&nbsp;rac&nbsp;eht&nbsp;teg&nbsp;lliw&nbsp;amliW&nbsp;dna.</bdo></samp>"</p>

</div>
<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>

<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>
<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>



Expand Down
31 changes: 22 additions & 9 deletions source
Expand Up @@ -99902,9 +99902,16 @@ time[datetime] { binding: <i title="">time</i>; }</pre>
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>
Expand All @@ -99923,7 +99930,8 @@ time[datetime] { binding: <i title="">time</i>; }</pre>

<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>
Expand All @@ -99933,15 +99941,20 @@ if (s = prompt('What is your name?')) {
car.</samp>". However, if the user enters "<kbd dir="rtl"
lang="ar">&#x644;&#x627;&nbsp;&#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;&nbsp;&#x623;&#x641;&#x647;&#x645;!&nbsp;derF&nbsp;,kO,&nbsp;&#x644;&#x627;&nbsp;&#x623;&#x641;&#x647;&#x645;,&nbsp;rac&nbsp;eht&nbsp;teg&nbsp;lliw&nbsp;amliW&nbsp;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;&nbsp;&#x623;&#x641;&#x647;&#x645;!&nbsp;derF&nbsp;,kO,&nbsp;&#x644;&#x627;&nbsp;&#x623;&#x641;&#x647;&#x645;,&nbsp;rac&nbsp;eht&nbsp;teg&nbsp;lliw&nbsp;amliW&nbsp;dna.</bdo></samp>"</p>

</div>
<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>

<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>
<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>



Expand Down

0 comments on commit 43dcea7

Please sign in to comment.