string-html.tq 4.61 KB
Newer Older
1 2 3 4
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

5
namespace string {
6 7 8 9 10 11 12 13 14 15 16 17
extern runtime StringEscapeQuotes(Context, String): String;

// https://tc39.github.io/ecma262/#sec-createhtml
transitioning builtin CreateHTML(implicit context: Context)(
    receiver: JSAny, methodName: String, tagName: String, attr: String,
    attrValue: JSAny): String {
  const tagContents: String = ToThisString(receiver, methodName);
  let result = '<' + tagName;
  if (attr != kEmptyString) {
    const attrStringValue: String =
        StringEscapeQuotes(context, ToString_Inline(attrValue));
    result = result + ' ' + attr + '=\"' + attrStringValue + '\"';
18 19
  }

20 21
  return result + '>' + tagContents + '</' + tagName + '>';
}
22

23 24 25 26 27 28
// https://tc39.github.io/ecma262/#sec-string.prototype.anchor
transitioning javascript builtin StringPrototypeAnchor(
    js-implicit context: NativeContext, receiver: JSAny)(...arguments): String {
  return CreateHTML(
      receiver, 'String.prototype.anchor', 'a', 'name', arguments[0]);
}
29

30 31 32 33 34 35 36
// https://tc39.github.io/ecma262/#sec-string.prototype.big
transitioning javascript builtin
StringPrototypeBig(
    js-implicit context: NativeContext, receiver: JSAny)(...arguments): String {
  return CreateHTML(
      receiver, 'String.prototype.big', 'big', kEmptyString, kEmptyString);
}
37

38 39 40 41 42 43 44
// https://tc39.github.io/ecma262/#sec-string.prototype.blink
transitioning javascript builtin
StringPrototypeBlink(
    js-implicit context: NativeContext, receiver: JSAny)(...arguments): String {
  return CreateHTML(
      receiver, 'String.prototype.blink', 'blink', kEmptyString, kEmptyString);
}
45

46 47 48 49 50 51 52
// https://tc39.github.io/ecma262/#sec-string.prototype.bold
transitioning javascript builtin
StringPrototypeBold(
    js-implicit context: NativeContext, receiver: JSAny)(...arguments): String {
  return CreateHTML(
      receiver, 'String.prototype.bold', 'b', kEmptyString, kEmptyString);
}
53

54 55 56 57 58 59 60
// https://tc39.github.io/ecma262/#sec-string.prototype.fontcolor
transitioning javascript builtin
StringPrototypeFontcolor(
    js-implicit context: NativeContext, receiver: JSAny)(...arguments): String {
  return CreateHTML(
      receiver, 'String.prototype.fontcolor', 'font', 'color', arguments[0]);
}
61

62 63 64 65 66 67 68
// https://tc39.github.io/ecma262/#sec-string.prototype.fontsize
transitioning javascript builtin
StringPrototypeFontsize(
    js-implicit context: NativeContext, receiver: JSAny)(...arguments): String {
  return CreateHTML(
      receiver, 'String.prototype.fontsize', 'font', 'size', arguments[0]);
}
69

70 71 72 73 74 75 76
// https://tc39.github.io/ecma262/#sec-string.prototype.fixed
transitioning javascript builtin
StringPrototypeFixed(
    js-implicit context: NativeContext, receiver: JSAny)(...arguments): String {
  return CreateHTML(
      receiver, 'String.prototype.fixed', 'tt', kEmptyString, kEmptyString);
}
77

78 79 80 81 82 83 84
// https://tc39.github.io/ecma262/#sec-string.prototype.italics
transitioning javascript builtin
StringPrototypeItalics(
    js-implicit context: NativeContext, receiver: JSAny)(...arguments): String {
  return CreateHTML(
      receiver, 'String.prototype.italics', 'i', kEmptyString, kEmptyString);
}
85

86 87 88 89 90 91 92
// https://tc39.github.io/ecma262/#sec-string.prototype.link
transitioning javascript builtin
StringPrototypeLink(
    js-implicit context: NativeContext, receiver: JSAny)(...arguments): String {
  return CreateHTML(
      receiver, 'String.prototype.link', 'a', 'href', arguments[0]);
}
93

94 95 96 97 98 99 100
// https://tc39.github.io/ecma262/#sec-string.prototype.small
transitioning javascript builtin
StringPrototypeSmall(
    js-implicit context: NativeContext, receiver: JSAny)(...arguments): String {
  return CreateHTML(
      receiver, 'String.prototype.small', 'small', kEmptyString, kEmptyString);
}
101

102 103 104 105 106 107 108 109
// https://tc39.github.io/ecma262/#sec-string.prototype.strike
transitioning javascript builtin
StringPrototypeStrike(
    js-implicit context: NativeContext, receiver: JSAny)(...arguments): String {
  return CreateHTML(
      receiver, 'String.prototype.strike', 'strike', kEmptyString,
      kEmptyString);
}
110

111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
// https://tc39.github.io/ecma262/#sec-string.prototype.sub
transitioning javascript builtin
StringPrototypeSub(
    js-implicit context: NativeContext, receiver: JSAny)(...arguments): String {
  return CreateHTML(
      receiver, 'String.prototype.sub', 'sub', kEmptyString, kEmptyString);
}

// https://tc39.github.io/ecma262/#sec-string.prototype.sup
transitioning javascript builtin
StringPrototypeSup(
    js-implicit context: NativeContext, receiver: JSAny)(...arguments): String {
  return CreateHTML(
      receiver, 'String.prototype.sup', 'sup', kEmptyString, kEmptyString);
}
126
}