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

이 부록에 정의된 ECMAScript 언어 구문과 의미는 ECMAScript 호스트가 웹 브라우저인 경우 필수이다. 이 부록의 내용은 규범적이지만 ECMAScript 호스트가 웹 브라우저가 아닌 경우 선택 사항이다.

이 부록에 정의된 일부 기능은 이 부록에서, 또 일부는 본문에서 정의된다.

기능이 본문에서 정의되는 경우, 문서에 영향을 미치는 각 지점은 색상 박스 안의 "Normative Optional" 문구로 표시된다. 또한 어떤 기능이 알고리즘이나 초기 에러 규칙의 특정 문구를 수반할 때는 그것이 관련 기능에 대해 “the host supports”하는 조건으로 보호된다. 웹 브라우저는 그러한 모든 기능을 지원해야 한다.

Note

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

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

B.1 추가 구문

B.1.1 HTML 유사 주석

12.4의 구문과 의미는 다음과 같이 확장되지만, 이 확장은 목표 심볼 Module 로 소스 텍스트를 파싱할 때는 허용되지 않는다:

구문

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

줄 종결자 코드 포인트를 포함하는 MultiLineComment 와 유사하게, SingleLineHTMLCloseComment 는 구문 문법에 의한 파싱 목적상 LineTerminator 로 간주된다.

B.1.2 정규 표현식 패턴

22.2.1의 구문은 다음과 같이 수정·확장된다. 이러한 변경은 문법 생성식의 순서 및 문맥 정보를 통해 해소되는 모호성을 도입한다. 아래 문법을 사용하여 파싱할 때 각 대안은 이전 생성식 대안이 일치하지 않을 경우에만 고려된다.

이 대안 패턴 문법과 의미는 BMP 패턴의 구문과 의미만 변경한다. 다음 문법 확장은 [UnicodeMode] 매개변수를 가진 생성식을 포함한다. 그러나 이러한 확장 중 어느 것도 목표 심볼에 [UnicodeMode] 매개변수가 존재할 때 인식되는 유니코드 패턴의 구문을 변경하지 않는다.

구문

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

동일한 좌변이 [+UnicodeMode] 와 [~UnicodeMode] 가드를 모두 가지는 경우 이는 모호성 해소 우선순위를 제어하기 위한 것이다.

B.1.2.1 정적 의미: 초기 에러

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

ExtendedAtom :: InvalidBracedQuantifier
  • 이 생성식이 어떤 소스 텍스트와 일치하면 Syntax Error 이다.

또한 다음 생성식의 규칙은 강조된 텍스트를 추가하여 수정된다:

NonemptyClassRanges :: ClassAtom - ClassAtom ClassContents
  • 첫 번째 ClassAtom 의 IsCharacterClass 가 true 이거나 두 번째 ClassAtom 의 IsCharacterClass 가 true 이고 이 생성식이 [UnicodeMode] 매개변수를 가진 경우 Syntax Error 이다.
  • 첫 번째 ClassAtom 의 IsCharacterClass 가 false, 두 번째 ClassAtom 의 IsCharacterClass 가 false 이고 첫 번째 ClassAtom 의 CharacterValue 가 두 번째 ClassAtom 의 CharacterValue 보다 엄격하게 크면 Syntax Error 이다.
NonemptyClassRangesNoDash :: ClassAtomNoDash - ClassAtom ClassContents
  • ClassAtomNoDash 의 IsCharacterClass 가 true 이거나 ClassAtom 의 IsCharacterClass 가 true 이고 이 생성식이 [UnicodeMode] 매개변수를 가진 경우 Syntax Error 이다.
  • ClassAtomNoDash 의 IsCharacterClass 가 false, ClassAtom 의 IsCharacterClass 가 false 이고 ClassAtomNoDash 의 CharacterValue 가 ClassAtom 의 CharacterValue 보다 엄격하게 크면 Syntax Error 이다.

B.1.2.2 정적 의미: CountLeftCapturingParensWithin 및 CountLeftCapturingParensBefore

CountLeftCapturingParensWithin 및 CountLeftCapturingParensBefore 정의에서 “ Atom :: ( GroupSpecifieropt Disjunction ) ”에 대한 참조는 “ Atom :: ( GroupSpecifieropt Disjunction ) ” 또는 “ ExtendedAtom :: ( GroupSpecifieropt Disjunction ) ”를 의미하는 것으로 해석된다.

B.1.2.3 정적 의미: IsCharacterClass

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

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

B.1.2.4 정적 의미: CharacterValue

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

ClassAtomNoDash :: \ [lookahead = c]
  1. U+005C (REVERSE SOLIDUS)의 숫자 값을 반환한다.
ClassEscape :: c ClassControlLetter
  1. chClassControlLetter 가 매칭한 코드 포인트로 둔다.
  2. ich 의 숫자 값으로 둔다.
  3. i 를 32로 나눈 나머지를 반환한다.
CharacterEscape :: LegacyOctalEscapeSequence
  1. LegacyOctalEscapeSequence 의 MV 를 반환한다(12.9.4.3 참조).

B.1.2.5 런타임 의미: CompileSubpattern

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

Term :: QuantifiableAssertion Quantifier 에 대한 규칙은 Atom 대신 QuantifiableAssertion 을 대입한 것을 제외하면 Term :: Atom Quantifier 의 규칙과 동일하다.

Term :: ExtendedAtom Quantifier 에 대한 규칙은 Atom 대신 ExtendedAtom 을 대입한 것을 제외하면 Term :: Atom Quantifier 와 동일하다.

Term :: ExtendedAtom 에 대한 규칙은 Atom 대신 ExtendedAtom 을 대입한 것을 제외하면 Term :: Atom 과 동일하다.

B.1.2.6 런타임 의미: CompileAssertion

Assertion :: (?= Disjunction ) Assertion :: (?! Disjunction ) 생성식에 대한 CompileAssertion 규칙은 Assertion 대신 QuantifiableAssertion 을 대입하여 QuantifiableAssertion 생성식에도 사용된다.

B.1.2.7 런타임 의미: CompileAtom

Atom :: PatternCharacter 를 제외한 Atom 생성식에 대한 CompileAtom 규칙은 Atom 대신 ExtendedAtom 을 대입하여 ExtendedAtom 생성식에도 사용된다. 다음 규칙(매개변수 direction)이 추가된다:

ExtendedAtom :: \ [lookahead = c]
  1. A 를 단일 문자 \ U+005C (REVERSE SOLIDUS)를 포함하는 CharSet 으로 둔다.
  2. CharacterSetMatcher(rer, A, false, direction) 를 반환한다.
ExtendedAtom :: ExtendedPatternCharacter
  1. chExtendedPatternCharacter 가 표현하는 문자로 둔다.
  2. A 를 문자 ch 하나만 포함하는 CharSet 으로 둔다.
  3. CharacterSetMatcher(rer, A, false, direction) 를 반환한다.

B.1.2.8 런타임 의미: CompileToCharSet

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

다음 두 규칙은 CompileToCharSet 의 해당 규칙을 대체한다.

NonemptyClassRanges :: ClassAtom - ClassAtom ClassContents
  1. A 를 첫 번째 ClassAtom 에 대한 CompileToCharSet(rer) 결과로 둔다.
  2. B 를 두 번째 ClassAtom 에 대한 CompileToCharSet(rer) 결과로 둔다.
  3. CClassContents 에 대한 CompileToCharSet(rer) 결과로 둔다.
  4. DCharacterRangeOrUnion(rer, A, B) 로 둔다.
  5. DC 의 합집합을 반환한다.
NonemptyClassRangesNoDash :: ClassAtomNoDash - ClassAtom ClassContents
  1. AClassAtomNoDash 에 대한 CompileToCharSet(rer) 결과로 둔다.
  2. BClassAtom 에 대한 CompileToCharSet(rer) 결과로 둔다.
  3. CClassContents 에 대한 CompileToCharSet(rer) 결과로 둔다.
  4. DCharacterRangeOrUnion(rer, A, B) 로 둔다.
  5. DC 의 합집합을 반환한다.

추가로 다음 규칙이 CompileToCharSet 에 추가된다.

ClassEscape :: c ClassControlLetter
  1. cv 를 이 ClassEscape 의 CharacterValue 로 둔다.
  2. c 를 문자 값이 cv 인 문자로 둔다.
  3. 문자 c 하나만 포함하는 CharSet 을 반환한다.
ClassAtomNoDash :: \ [lookahead = c]
  1. 단일 문자 \ U+005C (REVERSE SOLIDUS)를 포함하는 CharSet 을 반환한다.
Note
이 생성식은 허용 가능한 제어 문자가 뒤따르지 않는 문자 클래스 내부의 \c 시퀀스로부터만 도달될 수 있다.

B.1.2.8.1 CharacterRangeOrUnion ( rer, A, B )

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

  1. HasEitherUnicodeFlag(rer) 가 false 이면
    1. A 가 정확히 한 문자를 포함하지 않거나 B 가 정확히 한 문자를 포함하지 않으면
      1. C 를 단일 문자 - U+002D (HYPHEN-MINUS)를 포함하는 CharSet 으로 둔다.
      2. CharSet A, B, C 의 합집합을 반환한다.
  2. CharacterRange(A, B) 를 반환한다.

B.1.2.9 정적 의미: ParsePattern ( patternText, u, v )

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

추상 연산 ParsePattern 은 인수 patternText(유니코드 코드 포인트 시퀀스), u(Boolean), v(Boolean)을 받고 호출 시 다음 단계를 수행한다:

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

B.2 추가 내장 프로퍼티

ECMAScript 호스트가 웹 브라우저인 경우 표준 내장 객체의 다음 추가 프로퍼티가 정의된다.

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

Table 100의 항목을 Table 6에 추가한다.

Table 100: 추가 잘 알려진 내재 객체
Intrinsic Name Global Name ECMAScript Language Association
%escape% escape escape 함수 (B.2.1.1)
%unescape% unescape unescape 함수 (B.2.1.2)

B.2.1.1 escape ( string )

이 함수는 전역 객체의 프로퍼티이다. 특정 코드 유닛이 16진수 이스케이프 시퀀스로 교체된 새로운 String 값을 계산한다.

숫자 값이 0x00FF 이하인 코드 유닛을 교체할 때는 %xx 형태의 2자리 이스케이프 시퀀스를 사용한다. 숫자 값이 0x00FF 를 초과하는 코드 유닛을 교체할 때는 %uxxxx 형태의 4자리 이스케이프 시퀀스를 사용한다.

이것은 %escape% 내재 객체이다.

호출 시 다음 단계를 수행한다:

  1. string 을 ? ToString(string) 으로 설정한다.
  2. lenstring 의 길이로 둔다.
  3. R 을 빈 String 으로 둔다.
  4. unescapedSet 을 ASCII 단어 문자와 "@*+-./" 의 문자열 연결로 둔다.
  5. k 를 0으로 둔다.
  6. 반복, k < len 인 동안
    1. Cstring 내 인덱스 k 의 코드 유닛으로 둔다.
    2. unescapedSetC 를 포함하면
      1. SC 로 둔다.
    3. 아니면
      1. nC 의 숫자 값으로 둔다.
      2. n < 256 이면
        1. hexn 을 대문자 16진수로 서식화한 String 표현으로 둔다.
        2. S"%"StringPad(hex, 2, "0", start) 의 문자열 연결로 둔다.
      3. 그렇지 않으면
        1. hexn 을 대문자 16진수로 서식화한 String 표현으로 둔다.
        2. S"%u"StringPad(hex, 4, "0", start) 의 문자열 연결로 둔다.
    4. RRS 의 문자열 연결로 설정한다.
    5. kk + 1 로 설정한다.
  7. R 을 반환한다.
Note

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

B.2.1.2 unescape ( string )

이 함수는 전역 객체의 프로퍼티이다. escape 함수가 도입했을 수 있는 형태의 각 이스케이프 시퀀스를 그것이 표현하는 코드 유닛으로 교체한 새로운 String 값을 계산한다.

이것은 %unescape% 내재 객체이다.

호출 시 다음 단계를 수행한다:

  1. string 을 ? ToString(string) 으로 설정한다.
  2. lenstring 의 길이로 둔다.
  3. R 을 빈 String 으로 둔다.
  4. k 를 0으로 둔다.
  5. 반복, k < len 인 동안
    1. Cstring 내 인덱스 k 의 코드 유닛으로 둔다.
    2. C 가 코드 유닛 0x0025 (PERCENT SIGN)이면
      1. hexDigits 를 빈 String 으로 둔다.
      2. optionalAdvance 를 0으로 둔다.
      3. k + 5 < len 이고 string 내 인덱스 k + 1 의 코드 유닛이 0x0075 (LATIN SMALL LETTER U)이면
        1. hexDigitsstringk + 2 부터 k + 6 까지의 부분 문자열로 설정한다.
        2. optionalAdvance 를 5로 설정한다.
      4. Else if k + 3 ≤ len 이면
        1. hexDigitsstringk + 1 부터 k + 3 까지의 부분 문자열로 설정한다.
        2. optionalAdvance 를 2로 설정한다.
      5. parseResult 를 ParseText(hexDigits, HexDigits[~Sep]) 로 둔다.
      6. parseResult 가 Parse Node 이면
        1. nparseResult 의 MV 로 둔다.
        2. C 를 숫자 값이 n 인 코드 유닛으로 설정한다.
        3. kk + optionalAdvance 로 설정한다.
    3. RRC 의 문자열 연결로 설정한다.
    4. kk + 1 로 설정한다.
  6. R 을 반환한다.

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

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

이 메서드는 this 값을 String 으로 변환한 결과에서 인덱스 start 에서 시작하여 length 코드 유닛(또는 lengthundefined 이면 문자열 끝까지) 길이의 substring 을 반환한다. start 가 음수이면 sourceLength 를 문자열 길이로 하여 sourceLength + start 로 처리한다. 결과는 String 객체가 아닌 String 값이다.

호출 시 다음 단계를 수행한다:

  1. Othis 값으로 둔다.
  2. RequireObjectCoercible(O) 를 수행한다.
  3. S 를 ? ToString(O) 로 둔다.
  4. sizeS 의 길이로 둔다.
  5. intStart 를 ? ToIntegerOrInfinity(start) 로 둔다.
  6. intStart = -∞ 이면 intStart 를 0으로 설정한다.
  7. Else if intStart < 0 이면 intStartmax(size + intStart, 0) 으로 설정한다.
  8. Else, intStartmin(intStart, size) 로 설정한다.
  9. lengthundefined 이면 intLengthsize 로; 그렇지 않으면 intLength 를 ? ToIntegerOrInfinity(length) 로 둔다.
  10. intLength 를 0 과 size 사이로 클램프한 결과로 설정한다.
  11. intEndmin(intStart + intLength, size) 로 둔다.
  12. SintStart 부터 intEnd 까지의 substring 을 반환한다.
Note

이 메서드는 의도적으로 제네릭하다; this 값이 String 객체일 필요가 없다. 따라서 다른 종류의 객체에 메서드로 이전하여 사용할 수 있다.

B.2.2.2 String.prototype.anchor ( name )

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

  1. Sthis 값으로 둔다.
  2. CreateHTML(S, "a", "name", name) 를 반환한다.

B.2.2.2.1 CreateHTML ( string, tag, attribute, value )

The abstract operation CreateHTML takes arguments string (an ECMAScript language value), tag (a String), attribute (a String), and value (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(string) 를 수행한다.
  2. S 를 ? ToString(string) 로 둔다.
  3. p1"<"tag 의 문자열 연결로 둔다.
  4. attribute 가 빈 String 이 아니면
    1. V 를 ? ToString(value) 로 둔다.
    2. escapedVV 와 같되 V 내 코드 유닛 0x0022 (QUOTATION MARK) 의 각 출현이 6 코드 유닛 "&quot;" 로 대체된 String 값으로 둔다.
    3. p1 을 다음의 문자열 연결로 설정한다:
      • p1
      • 코드 유닛 0x0020 (SPACE)
      • attribute
      • 코드 유닛 0x003D (EQUALS SIGN)
      • 코드 유닛 0x0022 (QUOTATION MARK)
      • escapedV
      • 코드 유닛 0x0022 (QUOTATION MARK)
  5. p2p1">" 의 문자열 연결로 둔다.
  6. p3p2S 의 문자열 연결로 둔다.
  7. p4p3, "</", tag, ">" 의 문자열 연결로 둔다.
  8. p4 를 반환한다.

B.2.2.3 String.prototype.big ( )

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

  1. Sthis 값으로 둔다.
  2. CreateHTML(S, "big", "", "") 를 반환한다.

B.2.2.4 String.prototype.blink ( )

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

  1. Sthis 값으로 둔다.
  2. CreateHTML(S, "blink", "", "") 를 반환한다.

B.2.2.5 String.prototype.bold ( )

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

  1. Sthis 값으로 둔다.
  2. CreateHTML(S, "b", "", "") 를 반환한다.

B.2.2.6 String.prototype.fixed ( )

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

  1. Sthis 값으로 둔다.
  2. CreateHTML(S, "tt", "", "") 를 반환한다.

B.2.2.7 String.prototype.fontcolor ( colour )

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

  1. Sthis 값으로 둔다.
  2. CreateHTML(S, "font", "color", colour) 를 반환한다.

B.2.2.8 String.prototype.fontsize ( size )

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

  1. Sthis 값으로 둔다.
  2. CreateHTML(S, "font", "size", size) 를 반환한다.

B.2.2.9 String.prototype.italics ( )

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

  1. Sthis 값으로 둔다.
  2. CreateHTML(S, "i", "", "") 를 반환한다.

B.2.2.10 String.prototype.link ( url )

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

  1. Sthis 값으로 둔다.
  2. CreateHTML(S, "a", "href", url) 를 반환한다.

B.2.2.11 String.prototype.small ( )

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

  1. Sthis 값으로 둔다.
  2. CreateHTML(S, "small", "", "") 를 반환한다.

B.2.2.12 String.prototype.strike ( )

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

  1. Sthis 값으로 둔다.
  2. CreateHTML(S, "strike", "", "") 를 반환한다.

B.2.2.13 String.prototype.sub ( )

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

  1. Sthis 값으로 둔다.
  2. CreateHTML(S, "sub", "", "") 를 반환한다.

B.2.2.14 String.prototype.sup ( )

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

  1. Sthis 값으로 둔다.
  2. CreateHTML(S, "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 문제”를 피하기 때문에 거의 모든 용도에 더 권장된다.

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

  1. dateObjectthis 값으로 둔다.
  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 문제”를 피하기 때문에 거의 모든 용도에 더 권장된다.

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

  1. dateObjectthis 값으로 둔다.
  2. RequireInternalSlot(dateObject, [[DateValue]]) 를 수행한다.
  3. tdateObject.[[DateValue]] 로 둔다.
  4. y 를 ? ToNumber(year) 로 둔다.
  5. tNaN 이면 t+0𝔽 로; 아니면 tLocalTime(t) 로 설정한다.
  6. yyyyMakeFullYear(y) 로 둔다.
  7. dMakeDay(yyyy, MonthFromTime(t), DateFromTime(t)) 로 둔다.
  8. dateMakeDate(d, TimeWithinDay(t)) 로 둔다.
  9. uTimeClip(UTC(date)) 로 둔다.
  10. dateObject.[[DateValue]]u 로 설정한다.
  11. u 를 반환한다.

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. Othis 값으로 둔다.
  2. RequireInternalSlot(O, [[RegExpMatcher]]) 를 수행한다.
  3. pattern 이 Object 이고 [[RegExpMatcher]] 내부 슬롯을 가지면
    1. flagsundefined 가 아니면 TypeError 예외를 던진다.
    2. Ppattern.[[OriginalSource]] 로 둔다.
    3. Fpattern.[[OriginalFlags]] 로 둔다.
  4. 아니면
    1. Ppattern 으로 둔다.
    2. Fflags 로 둔다.
  5. RegExpInitialize(O, P, F) 를 반환한다.
Note

이 메서드는 this 값 RegExp 를 새로운 패턴과 플래그로 완전히 재초기화한다. 구현은 이 메서드 사용을 결과 RegExp 객체가 여러 번 사용될 것이며 추가 최적화 후보라는 주장으로 해석할 수 있다.

B.3 기타 추가 기능

B.3.1 레이블된 함수 선언

ECMAScript 2015 이전에는 LabelledStatement 의 명세가 문장 레이블을 FunctionDeclaration 과 연결하는 것을 허용하지 않았다. 그러나 레이블된 FunctionDeclaration 은 비엄격 코드에 대한 허용 확장이었고 대부분의 브라우저 호스트 ECMAScript 구현이 이를 지원했다. ECMAScript 2015 이후 문법 생성식 LabelledStatementFunctionDeclarationLabelledItem 으로 사용하는 것을 허용하지만 14.13.1 는 그것이 발생하면 Syntax Error 를 생성하는 초기 에러 규칙을 포함한다. 그 규칙은 호스트가 이 기능을 지원하는 비엄격 코드에서 Syntax Error 를 억제하도록 수정된다.

Note

WithStatement, IfStatement, IterationStatement 의 초기 에러 규칙은 비엄격 코드에서 이러한 문장이 레이블된 FunctionDeclaration 을 포함하는 것을 방지한다.

B.3.2 블록 수준 함수 선언 웹 레거시 호환 의미

ECMAScript 2015 이전에는 Block 문장의 StatementList 요소로 FunctionDeclaration 이 등장하는 것이 ECMAScript 명세에 정의되지 않았다. 그러나 해당 형태의 FunctionDeclaration 지원은 허용 확장이었고 대부분의 브라우저 호스트 ECMAScript 구현이 이를 허용했다. 불행히도 그러한 선언의 의미는 구현마다 다르다. 이러한 의미 차이 때문에 Block 수준 함수 선언을 사용하는 기존 웹 ECMAScript 소스 텍스트는 그러한 선언에 대해 모든 브라우저 구현의 의미 교집합에만 의존하는 경우에만 브라우저 구현 간 이식 가능하다. 다음이 그 교집합 의미에 속하는 사용 사례이다:

  1. 함수가 선언되고 단일 블록 내에서만 참조된다.

  2. 함수가 단일 Block 내에서 선언 및 사용될 수 있지만 동일한 Block 에 포함되지 않은 내부 함수 정의에서 참조된다.

    • 이름 fBindingIdentifier 를 가진 하나 이상의 FunctionDeclaration 이 둘러싼 함수 g 의 함수 코드 내에 나타나고 그 선언은 Block 에 중첩된다.
    • g 의 함수 코드 내에 var 선언이 아닌 다른 f 선언이 존재하지 않는다.
    • fIdentifierReference 출현이 선언을 포함하는 BlockStatementList 내에 있을 수 있다.
    • g 에 중첩된 다른 함수 h 내에 fIdentifierReference 출현이 적어도 하나 있고, h 로부터 f 참조를 가리는 다른 f 선언이 없다.
    • h 의 모든 호출은 f 선언이 평가된 이후에 발생한다.
  3. 함수가 단일 블록에서 선언 및 사용될 수 있지만 후속 블록에서 참조된다.

    • 이름 fBindingIdentifier 를 가진 하나 이상의 FunctionDeclaration 이 둘러싼 함수 g 의 함수 코드 내에 나타나고 그 선언은 Block 에 중첩된다.
    • g 의 함수 코드 내에 var 선언이 아닌 다른 f 선언이 존재하지 않는다.
    • fIdentifierReference 출현이 선언을 포함하는 BlockStatementList 내에 있을 수 있다.
    • f 선언을 포함하는 Block 을 어휘적으로 뒤따르는 g 의 함수 코드 내에 fIdentifierReference 출현이 적어도 하나 있다.

첫 번째 사용 사례는 ECMAScript 2015 가 제공하는 Block 수준 함수 선언 의미와 상호 운용된다. 그 사용 사례를 사용하는 모든 기존 ECMAScript 소스 텍스트는 10, 14, 15 절에 의해 정의된 블록 수준 함수 선언 의미를 사용하여 동작한다.

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

ECMAScript 구현에 진단 경고 메시지를 보고하는 메커니즘이 있는 경우, 이러한 호환 의미가 적용되어 비호환 의미와 관찰 가능한 차이를 만드는 FunctionDeclaration 이 있는 코드를 포함하면 경고가 생성되어야 한다. 예를 들어, var 바인딩 도입이 초기 에러를 만들기 때문에 도입되지 않는 경우 경고 메시지는 생성되지 않아야 한다.

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

B.3.3 IfStatement 문 절의 FunctionDeclaration

다음은 14.6IfStatement 생성식을 확장한다:

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]

이 생성식은 비엄격 코드를 파싱할 때만 적용된다. 이 생성식과 일치하는 소스 텍스트는 각 FunctionDeclaration[?Yield, ?Await, ~Default] 출현이 소스 텍스트에서 그 위치를 차지하는 BlockStatement 의 유일한 StatementListItem 인 것처럼 처리된다. 그러한 합성 BlockStatement 의 의미에는 B.3.2 에 명시된 웹 레거시 호환 의미가 포함된다.

B.3.4 Catch 블록 내 VariableStatement

이 기능에서는 Catch 절의 BlockCatchParameter 에 의해 바인딩된 이름을 또한 바인딩하는 var 선언을 포함할 수 있다. 이는 Catch : catch ( CatchParameter ) Block 에 대한 14.15.1 의 초기 에러 규칙을 수정하여 달성된다.

Note

런타임에는 이러한 바인딩이 VariableDeclarationEnvironment 에서 인스턴스화된다. 이들은 CatchParameter 가 도입한 동일 이름 바인딩을 가리지 않으므로 해당 var 선언의 Initializervar 바인딩이 아니라 대응 catch 매개변수에 할당한다.

이 수정된 동작은 Catch 절의 Block 내 직접 eval 호출로 도입된 varfunction 선언에도 적용된다. 이 변경은 EvalDeclarationInstantiation3.d.i.2.a.i13.b.ii.4.a.i.i 단계를 수정하여 달성된다.

B.3.5 ForIn 문 Head 의 Initializer

다음은 14.7.5ForInOfStatement 생성식을 확장한다:

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

이 생성식은 비엄격 코드를 파싱할 때만 적용된다.

8.3.1 의 ContainsDuplicateLabels 정적 의미는 다음으로 확장된다:

ForInOfStatement : for ( var BindingIdentifier Initializer in Expression ) Statement
  1. Statement 의 ContainsDuplicateLabels(labelSet) 를 반환한다.

8.3.2 의 ContainsUndefinedBreakTarget 정적 의미는 다음으로 확장된다:

ForInOfStatement : for ( var BindingIdentifier Initializer in Expression ) Statement
  1. Statement 의 ContainsUndefinedBreakTarget(labelSet) 를 반환한다.

8.3.3 의 ContainsUndefinedContinueTarget 정적 의미는 다음으로 확장된다:

ForInOfStatement : for ( var BindingIdentifier Initializer in Expression ) Statement
  1. Statement 의 ContainsUndefinedContinueTarget(iterationSet, « ») 를 반환한다.

14.7.5.2 의 IsDestructuring 정적 의미는 다음으로 확장된다:

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

8.2.6 의 VarDeclaredNames 정적 의미는 다음으로 확장된다:

ForInOfStatement : for ( var BindingIdentifier Initializer in Expression ) Statement
  1. names1BindingIdentifier 의 BoundNames 로 둔다.
  2. names2Statement 의 VarDeclaredNames 로 둔다.
  3. names1names2 의 리스트 연결을 반환한다.

8.2.7 의 VarScopedDeclarations 정적 의미는 다음으로 확장된다:

ForInOfStatement : for ( var BindingIdentifier Initializer in Expression ) Statement
  1. declarations1 을 « BindingIdentifier » 로 둔다.
  2. declarations2Statement 의 VarScopedDeclarations 로 둔다.
  3. declarations1declarations2 의 리스트 연결을 반환한다.

14.7.5.5 의 ForInOfLoopEvaluation 런타임 의미는 다음으로 확장된다:

ForInOfStatement : for ( var BindingIdentifier Initializer in Expression ) Statement
  1. bindingIdBindingIdentifier 의 StringValue 로 둔다.
  2. lhs 를 ? ResolveBinding(bindingId) 로 둔다.
  3. IsAnonymousFunctionDefinition(Initializer) 이 true 이면
    1. valueInitializer 의 NamedEvaluation(bindingId) 로 둔다.
  4. Else,
    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]] 내부 슬롯호스트 정의 객체에 존재할 수 있다. [[IsHTMLDDA]] 내부 슬롯을 가진 객체는 ToBoolean, IsLooselyEqual 추상 연산 및 typeof 연산자의 피연산자로 사용될 때 undefined 처럼 동작한다.

Note

[[IsHTMLDDA]] 내부 슬롯을 가진 객체는 이 명세에서 생성되지 않는다. 그러나 웹 브라우저의 document.all 객체 는 웹 호환성 목적을 위해 이 슬롯을 가진 호스트 정의 특이 객체이다. 이 종류 객체의 다른 알려진 예는 없으며 구현에서는 document.all 을 제외하고 새로 만들지 않아야 한다.

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

B.3.7 HostMakeJobCallback 의 비기본 동작

HostMakeJobCallback 추상 연산은 웹 브라우저인 호스트가 비기본 동작을 지정할 수 있게 한다.

B.3.8 HostEnsureCanAddPrivateElement 의 비기본 동작

HostEnsureCanAddPrivateElement 추상 연산은 웹 브라우저인 호스트가 비기본 동작을 지정할 수 있게 한다.

B.3.9 함수 호출 대입 대상으로 인한 런타임 에러

함수 호출(13.3.6)이 비엄격 코드에서 대입 대상(assignment target)으로 사용될 때 초기 에러를 생성하는 대신 평가 중 ReferenceError 예외가 발생한다.

Note

대입 대상이 AssignmentExpressionLeftHandSideExpression 인 경우 대입 연산자는 = 또는 AssignmentOperator 여야 한다; 특히 논리 대입 연산자(??=, &&=, ||=)에는 이 허용이 적용되지 않는다.

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