A user account is required in order to edit this wiki, but we've had to disable public user registrations due to spam.

To request an account, ask an autoconfirmed user on IRC (such as one of these permanent autoconfirmed members).

Difference between revisions of "Web ECMAScript"

From WHATWG Wiki
Jump to: navigation, search
(Start page for ECMAScript things needed on the web)
 
Line 8: Line 8:
  
 
Algorithm ToHTMLTag(tag_name, content, attribute_name, attribute_value):
 
Algorithm ToHTMLTag(tag_name, content, attribute_name, attribute_value):
if attribute_name is undefined return "<" + tag_name + ">" + content + "</" + tag_name + ">"
+
#if attribute_name is undefined return "<" + tag_name + ">" + content + "</" + tag_name + ">"
otherwise return "<" + tag_name + " " + attribute_name "=" "\"" + attribute_value + "\"" ">" + content + "</" + tag_name + ">"
+
#otherwise return "<" + tag_name + " " + attribute_name "=" "\"" + attribute_value + "\"" ">" + content + "</" + tag_name + ">"
  
 
=== String.prototype.anchor(name) ===
 
=== String.prototype.anchor(name) ===
  
1. Let content be ToString(this)
+
# Let content be ToString(this)
2. Let n be ToString(name)
+
# Let n be ToString(name)
3. Return ToHTMLTag("a", content, "name", n)
+
# Return ToHTMLTag("a", content, "name", n)
  
 
=== String.prototype.big() ===
 
=== String.prototype.big() ===
  
1. Let content be ToString(this)
+
# Let content be ToString(this)
2. Return ToHTMLTag("big", content)
+
# Return ToHTMLTag("big", content)
  
 
=== String.prototype.blink() ===
 
=== String.prototype.blink() ===
  
1. Let content be ToString(this)
+
# Let content be ToString(this)
2. Return ToHTMLTag("blink", content)
+
# Return ToHTMLTag("blink", content)
  
 
=== String.prototype.bold() ===
 
=== String.prototype.bold() ===
  
1. Let content be ToString(this)
+
# Let content be ToString(this)
2. Return ToHTMLTag("bold", content)
+
# Return ToHTMLTag("bold", content)
  
 
=== String.prototype.fixed() ===
 
=== String.prototype.fixed() ===
  
1. Let content be ToString(this)
+
# Let content be ToString(this)
2. Return ToHTMLTag("tt", content)
+
# Return ToHTMLTag("tt", content)
  
 
=== String.prototype.fontcolor(color) ===
 
=== String.prototype.fontcolor(color) ===
  
1. Let content be ToString(this)
+
# Let content be ToString(this)
2. Let attribute_value be ToString(color)
+
# Let attribute_value be ToString(color)
3. Return ToHTMLTag("font", content, "color", attribute_value)
+
# Return ToHTMLTag("font", content, "color", attribute_value)
  
 
=== String.prototype.fontsize(size) ===
 
=== String.prototype.fontsize(size) ===
  
1. Let content be ToString(this)
+
# Let content be ToString(this)
2. Let attribute_value be ToString(size)
+
# Let attribute_value be ToString(size)
3. Return ToHTMLTag("font", content, "size", attribute_value)
+
# Return ToHTMLTag("font", content, "size", attribute_value)
  
 
=== String.prototype.italics() ===
 
=== String.prototype.italics() ===
  
1. Let content be ToString(this)
+
# Let content be ToString(this)
2. Return ToHTMLTag("i", content)
+
# Return ToHTMLTag("i", content)
  
 
=== String.prototype.link ===
 
=== String.prototype.link ===
  
1. Let content be ToString(this)
+
# Let content be ToString(this)
2. Let attribute_value be ToString(href)
+
# Let attribute_value be ToString(href)
3. Return ToHTMLTag("a", content, "href", attribute_value)
+
# Return ToHTMLTag("a", content, "href", attribute_value)
  
 
=== String.prototype.small() ===
 
=== String.prototype.small() ===
  
1. Let content be ToString(this)
+
# Let content be ToString(this)
2. Return ToHTMLTag("small", content)
+
# Return ToHTMLTag("small", content)
  
 
=== String.prototype.strike() ===
 
=== String.prototype.strike() ===
  
1. Let content be ToString(this)
+
# Let content be ToString(this)
2. Return ToHTMLTag("strike", content)
+
# Return ToHTMLTag("strike", content)
  
 
=== String.prototype.sub() ===
 
=== String.prototype.sub() ===
  
1. Let content be ToString(this)
+
# Let content be ToString(this)
2. Return ToHTMLTag("sub", content)
+
# Return ToHTMLTag("sub", content)
  
 
=== String.prototype.sup() ===
 
=== String.prototype.sup() ===
  
1. Let content be ToString(this)
+
# Let content be ToString(this)
2. Return ToHTMLTag("sup", content)
+
# Return ToHTMLTag("sup", content)

Revision as of 10:05, 16 April 2009

Web ECMAScript

This page is for documenting the differences between the ES5 draft and the requirements for ECMAScript implementations in web browsers.

15.5.4 Properties of the String Prototype Object

Several extra methods are found on String.prototype for wrapping text in HTML elements (these are all generic; the this value need not be a String object):

Algorithm ToHTMLTag(tag_name, content, attribute_name, attribute_value):

  1. if attribute_name is undefined return "<" + tag_name + ">" + content + "</" + tag_name + ">"
  2. otherwise return "<" + tag_name + " " + attribute_name "=" "\"" + attribute_value + "\"" ">" + content + "</" + tag_name + ">"

String.prototype.anchor(name)

  1. Let content be ToString(this)
  2. Let n be ToString(name)
  3. Return ToHTMLTag("a", content, "name", n)

String.prototype.big()

  1. Let content be ToString(this)
  2. Return ToHTMLTag("big", content)

String.prototype.blink()

  1. Let content be ToString(this)
  2. Return ToHTMLTag("blink", content)

String.prototype.bold()

  1. Let content be ToString(this)
  2. Return ToHTMLTag("bold", content)

String.prototype.fixed()

  1. Let content be ToString(this)
  2. Return ToHTMLTag("tt", content)

String.prototype.fontcolor(color)

  1. Let content be ToString(this)
  2. Let attribute_value be ToString(color)
  3. Return ToHTMLTag("font", content, "color", attribute_value)

String.prototype.fontsize(size)

  1. Let content be ToString(this)
  2. Let attribute_value be ToString(size)
  3. Return ToHTMLTag("font", content, "size", attribute_value)

String.prototype.italics()

  1. Let content be ToString(this)
  2. Return ToHTMLTag("i", content)

String.prototype.link

  1. Let content be ToString(this)
  2. Let attribute_value be ToString(href)
  3. Return ToHTMLTag("a", content, "href", attribute_value)

String.prototype.small()

  1. Let content be ToString(this)
  2. Return ToHTMLTag("small", content)

String.prototype.strike()

  1. Let content be ToString(this)
  2. Return ToHTMLTag("strike", content)

String.prototype.sub()

  1. Let content be ToString(this)
  2. Return ToHTMLTag("sub", content)

String.prototype.sup()

  1. Let content be ToString(this)
  2. Return ToHTMLTag("sup", content)