Annex B (normative) 웹 브라우저를 위한 추가 ECMAScript 기능

이 annex에 정의된 ECMAScript 언어 구문과 의미론은 ECMAScript host가 웹 브라우저일 때 요구된다. 이 annex의 내용은 normative이지만 ECMAScript host가 웹 브라우저가 아닌 경우에는 선택 사항이다.

이 annex에 정의된 일부 기능은 이 annex에 명시되어 있고, 일부는 이 문서의 본문에 명시되어 있다.

기능이 본문에 명시된 경우, 그것이 문서에 영향을 미치는 각 지점은 색상 상자 안의 "Normative Optional"이라는 단어로 표시된다. 또한 그 기능이 알고리즘이나 early error 규칙의 특정 문구를 포함하는 경우, 이는 관련 기능을 “host가 지원한다”는 조건에 의해 보호된다. 웹 브라우저는 이러한 모든 기능을 지원해야 한다.

Note

이 annex는 웹 브라우저 ECMAScript host의 여러 legacy 기능과 기타 특성을 설명한다. 이 annex에 명시된 모든 언어 기능과 동작은 하나 이상의 바람직하지 않은 특성을 가지고 있으며 legacy 사용이 없다면 이 명세에서 제거되었을 것이다. 그러나 이러한 기능을 사용하는 기존 웹 페이지가 매우 많기 때문에 웹 브라우저는 이를 계속 지원해야 한다. 이 annex의 명세는 이러한 legacy 기능의 상호 운용 가능한 구현에 대한 요구 사항을 정의한다.

이러한 기능은 핵심 ECMAScript 언어의 일부로 간주되지 않는다. 프로그래머는 새로운 ECMAScript 코드를 작성할 때 이러한 기능과 동작을 사용하거나 그 존재를 가정해서는 안 된다. ECMAScript 구현은 해당 구현이 웹 브라우저의 일부이거나 웹 브라우저가 마주치는 동일한 legacy ECMAScript 코드를 실행해야 하는 경우가 아니라면 이러한 기능을 구현하지 않는 것이 권장된다.

B.1 추가 구문

B.1.1 HTML-like 주석

12.4의 구문과 의미론은 다음과 같이 확장된다. 단, goal symbol Module을 사용하여 source text를 파싱할 때는 이 확장이 허용되지 않는다:

구문

InputElementHashbangOrRegExp :: WhiteSpace LineTerminator Comment CommonToken HashbangComment RegularExpressionLiteral HTMLCloseComment Comment :: MultiLineComment SingleLineComment SingleLineHTMLOpenComment SingleLineHTMLCloseComment SingleLineDelimitedComment MultiLineComment :: /* FirstCommentLineopt LineTerminator MultiLineCommentCharsopt */ HTMLCloseCommentopt FirstCommentLine :: SingleLineDelimitedCommentChars SingleLineHTMLOpenComment :: <!-- SingleLineCommentCharsopt SingleLineHTMLCloseComment :: LineTerminatorSequence HTMLCloseComment SingleLineDelimitedComment :: /* SingleLineDelimitedCommentCharsopt */ HTMLCloseComment :: WhiteSpaceSequenceopt SingleLineDelimitedCommentSequenceopt --> SingleLineCommentCharsopt SingleLineDelimitedCommentChars :: SingleLineNotAsteriskChar SingleLineDelimitedCommentCharsopt * SingleLinePostAsteriskCommentCharsopt SingleLineNotAsteriskChar :: SourceCharacter but not one of * or LineTerminator SingleLinePostAsteriskCommentChars :: SingleLineNotForwardSlashOrAsteriskChar SingleLineDelimitedCommentCharsopt * SingleLinePostAsteriskCommentCharsopt SingleLineNotForwardSlashOrAsteriskChar :: SourceCharacter but not one of / or * or LineTerminator WhiteSpaceSequence :: WhiteSpace WhiteSpaceSequenceopt SingleLineDelimitedCommentSequence :: SingleLineDelimitedComment WhiteSpaceSequenceopt SingleLineDelimitedCommentSequenceopt

line terminator code point를 포함하는 MultiLineComment와 유사하게, SingleLineHTMLCloseComment는 syntactic grammar에 의한 파싱 목적상 LineTerminator로 간주된다.

B.1.2 정규 표현식 Pattern

22.2.1의 구문은 다음과 같이 수정 및 확장된다. 이러한 변경은 grammar production의 순서와 contextual information에 의해 해소되는 모호성을 도입한다. 다음 문법을 사용하여 파싱할 때, 각 alternative는 이전 production alternative가 일치하지 않는 경우에만 고려된다.

이 대체 pattern 문법과 의미론은 BMP pattern의 구문과 의미론만 변경한다. 다음 문법 확장은 [UnicodeMode] 매개변수로 매개변수화된 production을 포함한다. 그러나 이러한 확장은 goal symbol에 [UnicodeMode] 매개변수가 존재하는 상태로 파싱할 때 인식되는 Unicode pattern의 구문을 변경하지 않는다.

구문

Term[UnicodeMode, UnicodeSetsMode, NamedCaptureGroups] :: [+UnicodeMode] Assertion[+UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups] [+UnicodeMode] Atom[+UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups] Quantifier [+UnicodeMode] Atom[+UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups] [~UnicodeMode] QuantifiableAssertion[?NamedCaptureGroups] Quantifier [~UnicodeMode] Assertion[~UnicodeMode, ~UnicodeSetsMode, ?NamedCaptureGroups] [~UnicodeMode] ExtendedAtom[?NamedCaptureGroups] Quantifier [~UnicodeMode] ExtendedAtom[?NamedCaptureGroups] Assertion[UnicodeMode, UnicodeSetsMode, NamedCaptureGroups] :: ^ $ \b \B [+UnicodeMode] (?= Disjunction[+UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups] ) [+UnicodeMode] (?! Disjunction[+UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups] ) [~UnicodeMode] QuantifiableAssertion[?NamedCaptureGroups] (?<= Disjunction[?UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups] ) (?<! Disjunction[?UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups] ) QuantifiableAssertion[NamedCaptureGroups] :: (?= Disjunction[~UnicodeMode, ~UnicodeSetsMode, ?NamedCaptureGroups] ) (?! Disjunction[~UnicodeMode, ~UnicodeSetsMode, ?NamedCaptureGroups] ) ExtendedAtom[NamedCaptureGroups] :: . \ AtomEscape[~UnicodeMode, ?NamedCaptureGroups] \ [lookahead = c] CharacterClass[~UnicodeMode, ~UnicodeSetsMode] ( GroupSpecifier[~UnicodeMode]opt Disjunction[~UnicodeMode, ~UnicodeSetsMode, ?NamedCaptureGroups] ) (? RegularExpressionModifiers : Disjunction[~UnicodeMode, ~UnicodeSetsMode, ?NamedCaptureGroups] ) (? RegularExpressionModifiers - RegularExpressionModifiers : Disjunction[~UnicodeMode, ~UnicodeSetsMode, ?NamedCaptureGroups] ) InvalidBracedQuantifier ExtendedPatternCharacter InvalidBracedQuantifier :: { DecimalDigits[~Sep] } { DecimalDigits[~Sep] ,} { DecimalDigits[~Sep] , DecimalDigits[~Sep] } ExtendedPatternCharacter :: SourceCharacter but not one of ^ $ \ . * + ? ( ) [ | AtomEscape[UnicodeMode, NamedCaptureGroups] :: [+UnicodeMode] DecimalEscape [~UnicodeMode] DecimalEscape but only if the CapturingGroupNumber of DecimalEscape is ≤ CountLeftCapturingParensWithin(the Pattern containing DecimalEscape) CharacterClassEscape[?UnicodeMode] CharacterEscape[?UnicodeMode, ?NamedCaptureGroups] [+NamedCaptureGroups] k GroupName[?UnicodeMode] CharacterEscape[UnicodeMode, NamedCaptureGroups] :: ControlEscape c AsciiLetter 0 [lookahead ∉ DecimalDigit] HexEscapeSequence RegExpUnicodeEscapeSequence[?UnicodeMode] [~UnicodeMode] LegacyOctalEscapeSequence IdentityEscape[?UnicodeMode, ?NamedCaptureGroups] IdentityEscape[UnicodeMode, NamedCaptureGroups] :: [+UnicodeMode] SyntaxCharacter [+UnicodeMode] / [~UnicodeMode] SourceCharacterIdentityEscape[?NamedCaptureGroups] SourceCharacterIdentityEscape[NamedCaptureGroups] :: [~NamedCaptureGroups] SourceCharacter but not c [+NamedCaptureGroups] SourceCharacter but not one of c or k ClassAtomNoDash[UnicodeMode, NamedCaptureGroups] :: SourceCharacter but not one of \ or ] or - \ ClassEscape[?UnicodeMode, ?NamedCaptureGroups] \ [lookahead = c] ClassEscape[UnicodeMode, NamedCaptureGroups] :: b [+UnicodeMode] - [~UnicodeMode] c ClassControlLetter CharacterClassEscape[?UnicodeMode] CharacterEscape[?UnicodeMode, ?NamedCaptureGroups] ClassControlLetter :: DecimalDigit _ Note

같은 left-hand side가 [+UnicodeMode]와 [~UnicodeMode] guard 모두와 함께 나타나는 경우, 이는 disambiguation priority를 제어하기 위한 것이다.

B.1.2.1 Static Semantics: Early Errors

22.2.1.1의 의미론은 다음과 같이 확장된다:

ExtendedAtom :: InvalidBracedQuantifier
  • source text가 이 production과 일치하면 Syntax Error이다.

추가로, 다음 production에 대한 규칙은 highlighted text의 추가로 수정된다:

NonemptyClassRanges :: ClassAtom - ClassAtom ClassContents NonemptyClassRangesNoDash :: ClassAtomNoDash - ClassAtom ClassContents

B.1.2.2 Static Semantics: CountLeftCapturingParensWithin 및 CountLeftCapturingParensBefore

CountLeftCapturingParensWithinCountLeftCapturingParensBefore의 정의에서 “ Atom :: ( GroupSpecifieropt Disjunction ) ”에 대한 참조는 “ Atom :: ( GroupSpecifieropt Disjunction ) ” 또는 “ ExtendedAtom :: ( GroupSpecifieropt Disjunction ) ”을 의미하는 것으로 해석되어야 한다.

B.1.2.3 Static Semantics: IsCharacterClass

22.2.1.6의 의미론은 다음과 같이 확장된다:

ClassAtomNoDash :: \ [lookahead = c]
  1. false를 반환한다.

B.1.2.4 Static Semantics: CharacterValue

22.2.1.7의 의미론은 다음과 같이 확장된다:

ClassAtomNoDash :: \ [lookahead = c]
  1. U+005C (REVERSE SOLIDUS)의 numeric value를 반환한다.
ClassEscape :: c ClassControlLetter
  1. chClassControlLetter가 일치시킨 code point로 둔다.
  2. ich의 numeric value로 둔다.
  3. i를 32로 나눈 나머지를 반환한다.
CharacterEscape :: LegacyOctalEscapeSequence
  1. LegacyOctalEscapeSequence의 MV를 반환한다(12.9.4.3 참조).

B.1.2.5 Runtime Semantics: CompileSubpattern

CompileSubpattern의 의미론은 다음과 같이 확장된다:

Term :: QuantifiableAssertion Quantifier 에 대한 규칙은 AtomQuantifiableAssertion로 대체한다는 점을 제외하고 Term :: Atom Quantifier 와 같다.

Term :: ExtendedAtom Quantifier 에 대한 규칙은 AtomExtendedAtom으로 대체한다는 점을 제외하고 Term :: Atom Quantifier 와 같다.

Term :: ExtendedAtom 에 대한 규칙은 AtomExtendedAtom으로 대체한다는 점을 제외하고 Term :: Atom 과 같다.

B.1.2.6 Runtime Semantics: CompileAssertion

Assertion :: (?= Disjunction ) Assertion :: (?! Disjunction ) production에 대한 CompileAssertion 규칙은 AssertionQuantifiableAssertion로 대체하여 QuantifiableAssertion production에도 사용된다.

B.1.2.7 Runtime Semantics: CompileAtom

Atom :: PatternCharacter 를 제외한 Atom production에 대한 CompileAtom 규칙은 AtomExtendedAtom으로 대체하여 ExtendedAtom production에도 사용된다. 매개변수 direction을 가진 다음 규칙도 추가된다:

ExtendedAtom :: \ [lookahead = c]
  1. charSet을 단일 문자 \ U+005C (REVERSE SOLIDUS)를 포함하는 CharSet으로 둔다.
  2. CharacterSetMatcher(regexpRecord, charSet, false, direction)를 반환한다.
ExtendedAtom :: ExtendedPatternCharacter
  1. chExtendedPatternCharacter가 나타내는 문자로 둔다.
  2. charSet을 문자 ch를 포함하는 one-element CharSet으로 둔다.
  3. CharacterSetMatcher(regexpRecord, charSet, false, direction)를 반환한다.

B.1.2.8 Runtime Semantics: CompileToCharSet

22.2.2.9의 의미론은 다음과 같이 확장된다:

다음 두 규칙은 CompileToCharSet의 대응하는 규칙을 대체한다.

NonemptyClassRanges :: ClassAtom - ClassAtom ClassContents
  1. charSet을 인수 regexpRecord를 가진 첫 번째 ClassAtomCompileToCharSet으로 둔다.
  2. otherSet을 인수 regexpRecord를 가진 두 번째 ClassAtomCompileToCharSet으로 둔다.
  3. remainingSet을 인수 regexpRecord를 가진 ClassContentsCompileToCharSet으로 둔다.
  4. rangeSetCharacterRangeOrUnion(regexpRecord, charSet, otherSet)으로 둔다.
  5. rangeSetremainingSet의 union을 반환한다.
NonemptyClassRangesNoDash :: ClassAtomNoDash - ClassAtom ClassContents
  1. charSet을 인수 regexpRecord를 가진 ClassAtomNoDashCompileToCharSet으로 둔다.
  2. otherSet을 인수 regexpRecord를 가진 ClassAtomCompileToCharSet으로 둔다.
  3. remainingSet을 인수 regexpRecord를 가진 ClassContentsCompileToCharSet으로 둔다.
  4. rangeSetCharacterRangeOrUnion(regexpRecord, charSet, otherSet)으로 둔다.
  5. rangeSetremainingSet의 union을 반환한다.

또한 다음 규칙이 CompileToCharSet에 추가된다.

ClassEscape :: c ClassControlLetter
  1. cv를 이 ClassEscapeCharacterValue로 둔다.
  2. c를 character value가 cv인 문자로 둔다.
  3. 단일 문자 c를 포함하는 CharSet을 반환한다.
ClassAtomNoDash :: \ [lookahead = c]
  1. 단일 문자 \ U+005C (REVERSE SOLIDUS)를 포함하는 CharSet을 반환한다.
Note
이 production은 character class 안에서 허용되는 control character가 뒤따르지 않는 sequence \c로부터만 도달할 수 있다.

B.1.2.8.1 CharacterRangeOrUnion ( regexpRecord, charSet, otherSet )

The abstract operation CharacterRangeOrUnion takes arguments regexpRecord (a RegExp Record), charSet (a CharSet), and otherSet (a CharSet) and returns a CharSet. It performs the following steps when called:

  1. HasEitherUnicodeFlag(regexpRecord)가 false이면,
    1. charSet이 정확히 하나의 문자를 포함하지 않거나 otherSet이 정확히 하나의 문자를 포함하지 않으면,
      1. remainingSet을 단일 문자 - U+002D (HYPHEN-MINUS)를 포함하는 CharSet으로 둔다.
      2. CharSet charSet, otherSetremainingSet의 union을 반환한다.
  2. CharacterRange(charSet, otherSet)를 반환한다.

B.1.2.9 Static Semantics: ParsePattern ( patternText, u, v )

22.2.3.4의 의미론은 다음과 같이 확장된다:

추상 연산 ParsePattern은 인수 patternText(Unicode code point의 sequence), u(Boolean), 그리고 v(Boolean)를 받는다. 호출될 때 다음 단계를 수행한다:

  1. vtrue이고 utrue이면,
    1. parseResult를 하나 이상의 SyntaxError 객체를 포함하는 List로 둔다.
  2. 그렇지 않고 vtrue이면,
    1. parseResultParseText(patternText, Pattern[+UnicodeMode, +UnicodeSetsMode, +NamedCaptureGroups])로 둔다.
  3. 그렇지 않고 utrue이면,
    1. parseResultParseText(patternText, Pattern[+UnicodeMode, ~UnicodeSetsMode, +NamedCaptureGroups])로 둔다.
  4. 그렇지 않으면,
    1. parseResultParseText(patternText, Pattern[~UnicodeMode, ~UnicodeSetsMode, ~NamedCaptureGroups])로 둔다.
    2. parseResult가 Parse Node이고 parseResultGroupName을 포함하면,
      1. parseResultParseText(patternText, Pattern[~UnicodeMode, ~UnicodeSetsMode, +NamedCaptureGroups])로 설정한다.
  5. parseResult를 반환한다.

B.2 추가 Built-in 프로퍼티

ECMAScript host가 웹 브라우저일 때 표준 built-in 객체의 다음 추가 프로퍼티가 정의된다.

B.2.1 전역 객체의 추가 프로퍼티

Table 98의 항목이 Table 6에 추가된다.

Table 98: 추가 Well-known Intrinsic 객체
Intrinsic 이름 전역 이름 ECMAScript 언어 연관
%escape% escape escape 함수(B.2.1.1)
%unescape% unescape unescape 함수(B.2.1.2)

B.2.1.1 escape ( string )

이 함수는 전역 객체의 프로퍼티이다. 특정 code unit이 hexadecimal escape sequence로 대체된 String 값의 새로운 버전을 계산한다.

numeric value가 0x00FF 이하인 code unit을 대체할 때는 %xx 형식의 두 자리 escape sequence가 사용된다. numeric value가 0x00FF보다 strictly greater인 code unit을 대체할 때는 %uxxxx 형식의 네 자리 escape sequence가 사용된다.

이는 %escape% intrinsic object이다.

호출될 때 다음 단계를 수행한다:

  1. string을 ? ToString(string)으로 설정한다.
  2. lenstring의 길이로 둔다.
  3. result를 빈 String으로 둔다.
  4. unescapedSet을 ASCII word character와 "@*+-./"의 string-concatenation으로 둔다.
  5. k를 0으로 둔다.
  6. k < len인 동안 반복한다,
    1. codeUnitstring 안의 index k에 있는 code unit으로 둔다.
    2. unescapedSetcodeUnit을 포함하면,
      1. strcodeUnit으로 둔다.
    3. 그렇지 않으면,
      1. ncodeUnit의 numeric value로 둔다.
      2. n < 256이면,
        1. hex를 uppercase hexadecimal number로 형식화된 n의 String 표현으로 둔다.
        2. str"%"StringPad(hex, 2, "0", start)의 string-concatenation으로 둔다.
      3. 그렇지 않으면,
        1. hex를 uppercase hexadecimal number로 형식화된 n의 String 표현으로 둔다.
        2. str"%u"StringPad(hex, 4, "0", start)의 string-concatenation으로 둔다.
    4. resultresultstr의 string-concatenation으로 설정한다.
    5. kk + 1로 설정한다.
  7. result를 반환한다.
Note

이 인코딩은 부분적으로 RFC 1738에 설명된 인코딩에 기반하지만, 이 표준에 명시된 전체 인코딩은 RFC 1738의 내용과 무관하게 위에 설명되어 있다. 이 인코딩은 RFC 3986에 의해 RFC 1738에 이루어진 변경을 반영하지 않는다.

B.2.1.2 unescape ( string )

이 함수는 전역 객체의 프로퍼티이다. escape 함수에 의해 도입될 수 있는 종류의 각 escape sequence가 그것이 나타내는 code unit으로 대체된 String 값의 새로운 버전을 계산한다.

이는 %unescape% intrinsic object이다.

호출될 때 다음 단계를 수행한다:

  1. string을 ? ToString(string)으로 설정한다.
  2. lenstring의 길이로 둔다.
  3. result를 빈 String으로 둔다.
  4. k를 0으로 둔다.
  5. k < len인 동안 반복한다,
    1. codeUnitstring 안의 index k에 있는 code unit으로 둔다.
    2. codeUnit이 code unit 0x0025 (PERCENT SIGN)이면,
      1. hexDigits를 빈 String으로 둔다.
      2. optionalAdvance를 0으로 둔다.
      3. k + 5 < len이고 string 안의 index k + 1에 있는 code unit이 code unit 0x0075 (LATIN SMALL LETTER U)이면,
        1. hexDigitsstringk + 2부터 k + 6까지의 substring으로 설정한다.
        2. optionalAdvance를 5로 설정한다.
      4. 그렇지 않고 k + 3 ≤ len이면,
        1. hexDigitsstringk + 1부터 k + 3까지의 substring으로 설정한다.
        2. optionalAdvance를 2로 설정한다.
      5. parseResultParseText(hexDigits, HexDigits[~Sep])로 둔다.
      6. parseResult가 Parse Node이면,
        1. nparseResult의 MV로 둔다.
        2. codeUnit을 numeric value가 n인 code unit으로 설정한다.
        3. kk + optionalAdvance로 설정한다.
    3. resultresultcodeUnit의 string-concatenation으로 설정한다.
    4. kk + 1로 설정한다.
  6. result를 반환한다.

B.2.2 String.prototype 객체의 추가 프로퍼티

B.2.2.1 String.prototype.substr ( start, length )

이 메서드는 this 값을 String으로 변환한 결과의 substring을 반환하며, index start에서 시작하여 length code unit만큼 진행한다(또는 lengthundefined이면 String의 끝까지). start가 음수이면, String의 길이인 sourceLength에 대해 sourceLength + start로 취급된다. 결과는 String 객체가 아니라 String 값이다.

호출될 때 다음 단계를 수행한다:

  1. objthis value로 둔다.
  2. RequireObjectCoercible(obj)를 수행한다.
  3. str을 ? ToString(obj)로 둔다.
  4. sizestr의 길이로 둔다.
  5. intStart를 ? ToIntegerOrInfinity(start)로 둔다.
  6. intStart = -∞이면, intStart를 0으로 설정한다.
  7. 그렇지 않고 intStart < 0이면, intStartmax(size + intStart, 0)으로 설정한다.
  8. 그렇지 않으면, intStartmin(intStart, size)로 설정한다.
  9. lengthundefined이면, intLengthsize로 둔다; 그렇지 않으면 intLength를 ? ToIntegerOrInfinity(length)로 둔다.
  10. intLength를 0과 size 사이로 clamp한 결과로 설정한다.
  11. intEndmin(intStart + intLength, size)로 둔다.
  12. strintStart부터 intEnd까지의 substring을 반환한다.
Note

이 메서드는 의도적으로 generic하다; this 값이 String 객체일 것을 요구하지 않는다. 따라서 다른 종류의 객체에 메서드로 사용되도록 이전될 수 있다.

B.2.2.2 String.prototype.anchor ( name )

이 메서드는 호출될 때 다음 단계를 수행한다:

  1. strthis value로 둔다.
  2. CreateHTML(str, "a", "name", name)를 반환한다.

B.2.2.2.1 CreateHTML ( contents, tag, attribute, attrValue )

The abstract operation CreateHTML takes arguments contents (an ECMAScript language value), tag (a String), attribute (a String), and attrValue (an ECMAScript language value) and returns either a normal completion containing a String or a throw completion. It performs the following steps when called:

  1. RequireObjectCoercible(contents)를 수행한다.
  2. contentsStr을 ? ToString(contents)로 둔다.
  3. p1"<"tag의 string-concatenation으로 둔다.
  4. attribute가 빈 String이 아니면,
    1. attrValueStr을 ? ToString(attrValue)로 둔다.
    2. escapedAttrValueattrValueStr 안의 code unit 0x0022 (QUOTATION MARK)의 각 occurrence가 여섯 code unit sequence "&quot;"로 대체된 것을 제외하면 attrValueStr와 같은 String 값으로 둔다.
    3. p1을 다음의 string-concatenation으로 설정한다:
      • p1
      • code unit 0x0020 (SPACE)
      • attribute
      • code unit 0x003D (EQUALS SIGN)
      • code unit 0x0022 (QUOTATION MARK)
      • escapedAttrValue
      • code unit 0x0022 (QUOTATION MARK)
  5. p2p1">"의 string-concatenation으로 둔다.
  6. p3p2contentsStr의 string-concatenation으로 둔다.
  7. p4p3, "</", tag, 그리고 ">"의 string-concatenation으로 둔다.
  8. p4를 반환한다.

B.2.2.3 String.prototype.big ( )

이 메서드는 호출될 때 다음 단계를 수행한다:

  1. strthis value로 둔다.
  2. CreateHTML(str, "big", "", "")를 반환한다.

B.2.2.4 String.prototype.blink ( )

이 메서드는 호출될 때 다음 단계를 수행한다:

  1. strthis value로 둔다.
  2. CreateHTML(str, "blink", "", "")를 반환한다.

B.2.2.5 String.prototype.bold ( )

이 메서드는 호출될 때 다음 단계를 수행한다:

  1. strthis value로 둔다.
  2. CreateHTML(str, "b", "", "")를 반환한다.

B.2.2.6 String.prototype.fixed ( )

이 메서드는 호출될 때 다음 단계를 수행한다:

  1. strthis value로 둔다.
  2. CreateHTML(str, "tt", "", "")를 반환한다.

B.2.2.7 String.prototype.fontcolor ( colour )

이 메서드는 호출될 때 다음 단계를 수행한다:

  1. strthis value로 둔다.
  2. CreateHTML(str, "font", "color", colour)를 반환한다.

B.2.2.8 String.prototype.fontsize ( size )

이 메서드는 호출될 때 다음 단계를 수행한다:

  1. strthis value로 둔다.
  2. CreateHTML(str, "font", "size", size)를 반환한다.

B.2.2.9 String.prototype.italics ( )

이 메서드는 호출될 때 다음 단계를 수행한다:

  1. strthis value로 둔다.
  2. CreateHTML(str, "i", "", "")를 반환한다.

B.2.2.10 String.prototype.link ( url )

이 메서드는 호출될 때 다음 단계를 수행한다:

  1. strthis value로 둔다.
  2. CreateHTML(str, "a", "href", url)를 반환한다.

B.2.2.11 String.prototype.small ( )

이 메서드는 호출될 때 다음 단계를 수행한다:

  1. strthis value로 둔다.
  2. CreateHTML(str, "small", "", "")를 반환한다.

B.2.2.12 String.prototype.strike ( )

이 메서드는 호출될 때 다음 단계를 수행한다:

  1. strthis value로 둔다.
  2. CreateHTML(str, "strike", "", "")를 반환한다.

B.2.2.13 String.prototype.sub ( )

이 메서드는 호출될 때 다음 단계를 수행한다:

  1. strthis value로 둔다.
  2. CreateHTML(str, "sub", "", "")를 반환한다.

B.2.2.14 String.prototype.sup ( )

이 메서드는 호출될 때 다음 단계를 수행한다:

  1. strthis value로 둔다.
  2. CreateHTML(str, "sup", "", "")를 반환한다.

B.2.2.15 String.prototype.trimLeft ( )

Note

"trimStart" 프로퍼티가 선호된다. "trimLeft" 프로퍼티는 주로 오래된 코드와의 호환성을 위해 제공된다. 새로운 ECMAScript 코드에서는 "trimStart" 프로퍼티를 사용하는 것이 권장된다.

"trimLeft" 프로퍼티의 초기 값은 22.1.3.34에 정의된 %String.prototype.trimStart%이다.

B.2.2.16 String.prototype.trimRight ( )

Note

"trimEnd" 프로퍼티가 선호된다. "trimRight" 프로퍼티는 주로 오래된 코드와의 호환성을 위해 제공된다. 새로운 ECMAScript 코드에서는 "trimEnd" 프로퍼티를 사용하는 것이 권장된다.

"trimRight" 프로퍼티의 초기 값은 22.1.3.33에 정의된 %String.prototype.trimEnd%이다.

B.2.3 Date.prototype 객체의 추가 프로퍼티

B.2.3.1 Date.prototype.getYear ( )

Note

getFullYear 메서드는 “year 2000 problem”을 피하기 때문에 거의 모든 목적에서 선호된다.

이 메서드는 호출될 때 다음 단계를 수행한다:

  1. dateObjectthis value로 둔다.
  2. RequireInternalSlot(dateObject, [[DateValue]])를 수행한다.
  3. tdateObject.[[DateValue]]로 둔다.
  4. tNaN이면, NaN을 반환한다.
  5. YearFromTime(LocalTime(t)) - 1900𝔽을 반환한다.

B.2.3.2 Date.prototype.setYear ( year )

Note

setFullYear 메서드는 “year 2000 problem”을 피하기 때문에 거의 모든 목적에서 선호된다.

이 메서드는 호출될 때 다음 단계를 수행한다:

  1. dateObjectthis value로 둔다.
  2. RequireInternalSlot(dateObject, [[DateValue]])를 수행한다.
  3. timedateObject.[[DateValue]]로 둔다.
  4. year를 ? ToNumber(year)로 둔다.
  5. timeNaN이면 time+0𝔽으로 설정한다; 그렇지 않으면 timeLocalTime(time)으로 설정한다.
  6. fullYearMakeFullYear(year)로 둔다.
  7. dayMakeDay(fullYear, MonthFromTime(time), DateFromTime(time))으로 둔다.
  8. dateMakeDate(day, TimeWithinDay(time))으로 둔다.
  9. utcTimestampTimeClip(UTC(date))로 둔다.
  10. dateObject.[[DateValue]]utcTimestamp로 설정한다.
  11. utcTimestamp를 반환한다.

B.2.3.3 Date.prototype.toGMTString ( )

Note

toUTCString 메서드가 선호된다. 이 메서드는 주로 오래된 코드와의 호환성을 위해 제공된다.

"toGMTString" 프로퍼티의 초기 값은 21.4.4.43에 정의된 %Date.prototype.toUTCString%이다.

B.2.4 RegExp.prototype 객체의 추가 프로퍼티

B.2.4.1 RegExp.prototype.compile ( pattern, flags )

이 메서드는 호출될 때 다음 단계를 수행한다:

  1. objthis value로 둔다.
  2. RequireInternalSlot(obj, [[RegExpMatcher]])를 수행한다.
  3. pattern이 Object이고 pattern[[RegExpMatcher]] 내부 슬롯을 가지면,
    1. flagsundefined가 아니면, TypeError 예외를 던진다.
    2. flagspattern.[[OriginalFlags]]로 설정한다.
    3. patternpattern.[[OriginalSource]]로 설정한다.
  4. RegExpInitialize(obj, pattern, flags)를 반환한다.
Note

이 메서드는 this value RegExp를 새로운 pattern과 flag로 완전히 다시 초기화한다. 구현은 이 메서드의 사용을 결과 RegExp 객체가 여러 번 사용될 것이라는 assertion으로 해석할 수 있으며, 따라서 추가 최적화의 후보로 볼 수 있다.

B.3 기타 추가 기능

B.3.1 Labelled Function Declaration

ECMAScript 2015 이전에는 LabelledStatement의 명세가 statement label과 FunctionDeclaration의 연결을 허용하지 않았다. 그러나 labelled FunctionDeclarationnon-strict 코드에 대해 허용 가능한 확장이었고, 대부분의 browser-hosted ECMAScript 구현은 그 확장을 지원했다. ECMAScript 2015 및 이후에서는 LabelledStatement의 grammar production이 FunctionDeclarationLabelledItem으로 사용하는 것을 허용하지만, 14.13.1는 그것이 발생하면 Syntax Error를 생성하는 Early Error 규칙을 포함한다. 그런 다음 host가 이 기능을 지원한다면 non-strict 코드에서 Syntax Error를 억제하도록 그 규칙이 수정된다.

Note

WithStatement, IfStatement, 그리고 IterationStatement에 대한 early error 규칙은 이러한 statement가 non-strict 코드에서 labelled FunctionDeclaration을 포함하는 것을 방지한다.

B.3.2 Block-Level Function Declaration 웹 Legacy 호환성 의미론

ECMAScript 2015 이전에는 ECMAScript 명세가 Block statement의 StatementList 요소로 FunctionDeclaration이 발생하는 것을 정의하지 않았다. 그러나 그런 형태의 FunctionDeclaration 지원은 허용 가능한 확장이었고 대부분의 browser-hosted ECMAScript 구현은 이를 허용했다. 불행히도 그러한 선언의 의미론은 구현마다 다르다. 이러한 의미론적 차이 때문에, Block level function declaration을 사용하는 기존 웹 ECMAScript source text는 그 사용이 그러한 선언에 대한 모든 브라우저 구현의 의미론적 교집합에만 의존할 때에만 브라우저 구현 간에 portable하다. 다음은 그 교집합 의미론 안에 들어가는 사용 사례이다:

  1. 함수가 선언되고 단일 block 안에서만 참조된다.

    • BindingIdentifier가 이름 f인 하나 이상의 FunctionDeclaration이 둘러싸는 함수 g의 function code 안에 발생하고, 그 선언이 Block 안에 중첩되어 있다.
    • var declaration이 아닌 f의 다른 선언이 g의 function code 안에 발생하지 않는다.
    • IdentifierReference로서의 f의 모든 occurrence는 f의 선언을 포함하는 BlockStatementList 안에 있다.
  2. 함수가 선언되고 단일 Block 안에서 사용될 수 있지만, 같은 Block 안에 포함되지 않은 inner function definition에서도 참조된다.

    • BindingIdentifier가 이름 f인 하나 이상의 FunctionDeclaration이 둘러싸는 함수 g의 function code 안에 발생하고, 그 선언이 Block 안에 중첩되어 있다.
    • var declaration이 아닌 f의 다른 선언이 g의 function code 안에 발생하지 않는다.
    • IdentifierReference로서의 f의 occurrence가 f의 선언을 포함하는 BlockStatementList 안에 있을 수 있다.
    • g 안에 중첩된 다른 함수 h 안에 IdentifierReference로서의 f의 occurrence가 최소 하나 있고, h 안에서 f에 대한 참조를 shadow하는 f의 다른 선언이 없다.
    • h의 모든 호출은 f의 선언이 평가된 뒤에 발생한다.
  3. 함수가 선언되고 단일 block 안에서 사용될 수 있지만, 이후 block 안에서도 참조된다.

    • BindingIdentifier가 이름 f인 하나 이상의 FunctionDeclaration이 둘러싸는 함수 g의 function code 안에 발생하고, 그 선언이 Block 안에 중첩되어 있다.
    • var declaration이 아닌 f의 다른 선언이 g의 function code 안에 발생하지 않는다.
    • IdentifierReference로서의 f의 occurrence가 f의 선언을 포함하는 BlockStatementList 안에 있을 수 있다.
    • g의 function code 안에, f의 선언을 포함하는 Block을 lexical하게 뒤따르는 IdentifierReference로서의 f의 occurrence가 최소 하나 있다.

첫 번째 사용 사례는 ECMAScript 2015가 제공하는 Block level function declaration의 의미론과 상호 운용 가능하다. 그 사용 사례를 채택하는 기존 ECMAScript source text는 10, 14, 그리고 15 절에 정의된 Block level function declaration 의미론을 사용하여 동작한다.

두 번째 및 세 번째 사용 사례에 대한 ECMAScript 2015 상호 운용성은 10 절, 15 절, 19.2.1 절 및 16.1.7 절 의미론에 대한 다음 확장을 요구한다.

ECMAScript 구현에 diagnostic warning message를 보고하는 메커니즘이 있다면, 이러한 compatibility semantics가 적용되고 non-compatibility semantics와 관찰 가능한 차이를 도입하는 FunctionDeclaration이 코드에 포함될 때 warning이 생성되어야 한다. 예를 들어, var binding의 도입이 early error를 만들기 때문에 var binding이 도입되지 않는 경우 warning message는 생성되지 않아야 한다.

이 기능은 다음 지점에서 특별한 의미론을 포함한다:

B.3.3 IfStatement Statement Clause 안의 FunctionDeclaration

다음은 14.6IfStatement production을 보강한다:

IfStatement[Yield, Await, Return] : if ( Expression[+In, ?Yield, ?Await] ) FunctionDeclaration[?Yield, ?Await, ~Default] else Statement[?Yield, ?Await, ?Return] if ( Expression[+In, ?Yield, ?Await] ) Statement[?Yield, ?Await, ?Return] else FunctionDeclaration[?Yield, ?Await, ~Default] if ( Expression[+In, ?Yield, ?Await] ) FunctionDeclaration[?Yield, ?Await, ~Default] else FunctionDeclaration[?Yield, ?Await, ~Default] if ( Expression[+In, ?Yield, ?Await] ) FunctionDeclaration[?Yield, ?Await, ~Default] [lookahead ≠ else]

이 production은 non-strict 코드를 파싱할 때에만 적용된다. 이 production과 일치하는 source text는 FunctionDeclaration[?Yield, ?Await, ~Default]의 각 일치 occurrence가 source text의 해당 위치를 차지하는 BlockStatement의 유일한 StatementListItem인 것처럼 처리된다. 그러한 synthetic BlockStatement의 의미론은 B.3.2에 명시된 web legacy compatibility semantics를 포함한다.

B.3.4 Catch Block 안의 VariableStatement

이 기능에서, Catch clause의 BlockCatchParameter에 의해 binding된 이름과 같은 이름을 bind하는 var declaration을 포함할 수 있다. 이는 14.15.1 안의 Catch : catch ( CatchParameter ) Block 에 대한 early error 규칙을 수정하여 달성된다.

Note

Runtime에서 그러한 binding은 VariableDeclarationEnvironment 안에 instantiate된다. 이들은 CatchParameter가 도입한 같은 이름의 binding을 shadow하지 않으므로, 그러한 var declaration의 Initializervar binding이 아니라 대응하는 catch parameter에 할당한다.

이 수정된 동작은 Catch clause의 Block 안에 포함된 direct eval call에 의해 도입되는 varfunction declaration에도 적용된다. 이 변경은 EvalDeclarationInstantiation 안의 단계 3.d.i.2.a.i13.b.ii.4.a.i.i를 수정하여 달성된다.

B.3.5 ForIn Statement Head 안의 Initializer

다음은 14.7.5ForInOfStatement production을 보강한다:

ForInOfStatement[Yield, Await, Return] : for ( var BindingIdentifier[?Yield, ?Await] Initializer[~In, ?Yield, ?Await] in Expression[+In, ?Yield, ?Await] ) Statement[?Yield, ?Await, ?Return]

이 production은 non-strict 코드를 파싱할 때에만 적용된다.

8.3.1ContainsDuplicateLabels static semantics는 다음으로 보강된다:

ForInOfStatement : for ( var BindingIdentifier Initializer in Expression ) Statement
  1. 인수 labelSet을 가진 StatementContainsDuplicateLabels를 반환한다.

8.3.2ContainsUndefinedBreakTarget static semantics는 다음으로 보강된다:

ForInOfStatement : for ( var BindingIdentifier Initializer in Expression ) Statement
  1. 인수 labelSet을 가진 StatementContainsUndefinedBreakTarget을 반환한다.

8.3.3ContainsUndefinedContinueTarget static semantics는 다음으로 보강된다:

ForInOfStatement : for ( var BindingIdentifier Initializer in Expression ) Statement
  1. 인수 iterationSet 및 « »를 가진 StatementContainsUndefinedContinueTarget을 반환한다.

14.7.5.2IsDestructuring static semantics는 다음으로 보강된다:

BindingIdentifier : Identifier yield await
  1. false를 반환한다.

8.2.6VarDeclaredNames static semantics는 다음으로 보강된다:

ForInOfStatement : for ( var BindingIdentifier Initializer in Expression ) Statement
  1. names1BindingIdentifierBoundNames로 둔다.
  2. names2StatementVarDeclaredNames로 둔다.
  3. names1names2list-concatenation을 반환한다.

8.2.7VarScopedDeclarations static semantics는 다음으로 보강된다:

ForInOfStatement : for ( var BindingIdentifier Initializer in Expression ) Statement
  1. declarations1을 « BindingIdentifier »로 둔다.
  2. declarations2StatementVarScopedDeclarations로 둔다.
  3. declarations1declarations2list-concatenation을 반환한다.

14.7.5.5ForInOfLoopEvaluation runtime semantics는 다음으로 보강된다:

ForInOfStatement : for ( var BindingIdentifier Initializer in Expression ) Statement
  1. bindingIdBindingIdentifierStringValue로 둔다.
  2. lhs를 ? ResolveBinding(bindingId)로 둔다.
  3. IsAnonymousFunctionDefinition(Initializer)가 true이면,
    1. value를 인수 bindingId를 가진 Initializer의 ? NamedEvaluation으로 둔다.
  4. 그렇지 않으면,
    1. rhsInitializer의 ? Evaluation으로 둔다.
    2. value를 ? GetValue(rhs)로 둔다.
  5. PutValue(lhs, value)를 수행한다.
  6. keyResult를 ? ForIn/OfHeadEvaluation(« », Expression, enumerate)로 둔다.
  7. ForIn/OfBodyEvaluation(BindingIdentifier, Statement, keyResult, enumerate, var-binding, labelSet)를 반환한다.

B.3.6 [[IsHTMLDDA]] 내부 슬롯

[[IsHTMLDDA]] internal slot은 host-defined 객체에 존재할 수 있다. [[IsHTMLDDA]] 내부 슬롯을 가진 객체는 ToBooleanIsLooselyEqual 추상 연산에서, 그리고 typeof 연산자의 operand로 사용될 때 undefined처럼 동작한다.

Note

[[IsHTMLDDA]] 내부 슬롯을 가진 객체는 이 명세에 의해 생성되지 않는다. 그러나 웹 브라우저의 document.all 객체는 웹 호환성을 위해 존재하는 이 슬롯을 가진 host-defined exotic object이다. 이 종류의 객체에 대한 다른 알려진 예는 없으며 구현은 document.all을 제외하고 이를 만들어서는 안 된다.

이 기능은 다음 지점에서 특별한 의미론을 포함한다:

B.3.7 HostMakeJobCallback의 non-default 동작

HostMakeJobCallback 추상 연산은 웹 브라우저인 host가 non-default 동작을 지정할 수 있게 한다.

B.3.8 HostEnsureCanAddPrivateElement의 non-default 동작

HostEnsureCanAddPrivateElement 추상 연산은 웹 브라우저인 host가 non-default 동작을 지정할 수 있게 한다.

B.3.9 Function Call Assignment Target에 대한 Runtime Error

function call(13.3.6)이 non-strict 코드에서 assignment target으로 사용될 때, early error를 생성하는 대신 assignment 평가 중 ReferenceError 예외가 던져진다.

Note

assignment target이 AssignmentExpressionLeftHandSideExpression이면, assignment operator는 = 또는 AssignmentOperator여야 한다; 특히 여기의 허용은 logical assignment operator(??=, &&=, ||=)에는 적용되지 않는다.

CallExpression : CoverCallExpressionAndAsyncArrowHead CallExpression : CallExpression Arguments 에 대한 AssignmentTargetType의 단계 1를 참조하라.