| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5236,8 +5236,7 @@ const own$6 = {}.hasOwnProperty; | |||
| 5236 | 5236 | * @returns {string|false} | |
| 5237 | 5237 | * Decoded reference. | |
| 5238 | 5238 | */ | |
| 5239 | - function decodeEntity(value) { | ||
| 5240 | - // @ts-expect-error: to do: use `Record` for `character-entities`. | ||
| 5239 | + function decodeNamedCharacterReference(value) { | ||
| 5241 | 5240 | return own$6.call(characterEntities, value) ? characterEntities[value] : false | |
| 5242 | 5241 | } | |
| 5243 | 5242 | ||
@@ -5319,7 +5318,7 @@ function tokenizeCharacterReference(effects, ok, nok) { | |||
| 5319 | 5318 | ||
| 5320 | 5319 | if ( | |
| 5321 | 5320 | test === asciiAlphanumeric && | |
| 5322 | - !decodeEntity(self.sliceSerialize(token)) | ||
| 5321 | + !decodeNamedCharacterReference(self.sliceSerialize(token)) | ||
| 5323 | 5322 | ) { | |
| 5324 | 5323 | return nok(code) | |
| 5325 | 5324 | } | |
@@ -10185,7 +10184,7 @@ function decode($0, $1, $2) { | |||
| 10185 | 10184 | return decodeNumericCharacterReference($2.slice(hex ? 2 : 1), hex ? 16 : 10) | |
| 10186 | 10185 | } | |
| 10187 | 10186 | ||
| 10188 | - return decodeEntity($2) || $0 | ||
| 10187 | + return decodeNamedCharacterReference($2) || $0 | ||
| 10189 | 10188 | } | |
| 10190 | 10189 | ||
| 10191 | 10190 | /** | |
@@ -10680,7 +10679,7 @@ function compiler(options = {}) { | |||
| 10680 | 10679 | * @this {CompileContext} | |
| 10681 | 10680 | * @param {N} node | |
| 10682 | 10681 | * @param {Token} token | |
| 10683 | - * @param {OnError} [errorHandler] | ||
| 10682 | + * @param {OnEnterError} [errorHandler] | ||
| 10684 | 10683 | * @returns {N} | |
| 10685 | 10684 | */ | |
| 10686 | 10685 | ||
@@ -10714,9 +10713,15 @@ function compiler(options = {}) { | |||
| 10714 | 10713 | exit.call(this, token); | |
| 10715 | 10714 | } | |
| 10716 | 10715 | } | |
| 10717 | - /** @type {CompileContext['exit']} */ | ||
| 10716 | + /** | ||
| 10717 | + * @type {CompileContext['exit']} | ||
| 10718 | + * @this {CompileContext} | ||
| 10719 | + * @param {Token} token | ||
| 10720 | + * @param {OnExitError} [onExitError] | ||
| 10721 | + * @returns {Node} | ||
| 10722 | + */ | ||
| 10718 | 10723 | ||
| 10719 | - function exit(token) { | ||
| 10724 | + function exit(token, onExitError) { | ||
| 10720 | 10725 | const node = this.stack.pop(); | |
| 10721 | 10726 | const open = this.tokenStack.pop(); | |
| 10722 | 10727 | ||
@@ -10732,8 +10737,12 @@ function compiler(options = {}) { | |||
| 10732 | 10737 | '): it’s not open' | |
| 10733 | 10738 | ) | |
| 10734 | 10739 | } else if (open[0].type !== token.type) { | |
| 10735 | - const handler = open[1] || defaultOnError; | ||
| 10736 | - handler.call(this, token, open[0]); | ||
| 10740 | + if (onExitError) { | ||
| 10741 | + onExitError.call(this, token, open[0]); | ||
| 10742 | + } else { | ||
| 10743 | + const handler = open[1] || defaultOnError; | ||
| 10744 | + handler.call(this, token, open[0]); | ||
| 10745 | + } | ||
| 10737 | 10746 | } | |
| 10738 | 10747 | ||
| 10739 | 10748 | node.position.end = point(token.end); | |
@@ -11093,9 +11102,10 @@ function compiler(options = {}) { | |||
| 11093 | 11102 | ); | |
| 11094 | 11103 | setData('characterReferenceType'); | |
| 11095 | 11104 | } else { | |
| 11096 | - // @ts-expect-error `decodeEntity` can return false for invalid named | ||
| 11097 | - // character references, but everything we’ve tokenized is valid. | ||
| 11098 | - value = decodeEntity(data); | ||
| 11105 | + // @ts-expect-error `decodeNamedCharacterReference` can return false for | ||
| 11106 | + // invalid named character references, but everything we’ve tokenized is | ||
| 11107 | + // valid. | ||
| 11108 | + value = decodeNamedCharacterReference(data); | ||
| 11099 | 11109 | } | |
| 11100 | 11110 | ||
| 11101 | 11111 | const tail = this.stack.pop(); | |
@@ -11325,7 +11335,7 @@ function extension(combined, extension) { | |||
| 11325 | 11335 | } | |
| 11326 | 11336 | } | |
| 11327 | 11337 | } | |
| 11328 | - /** @type {OnError} */ | ||
| 11338 | + /** @type {OnEnterError} */ | ||
| 11329 | 11339 | ||
| 11330 | 11340 | function defaultOnError(left, right) { | |
| 11331 | 11341 | if (left) { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments