1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-26 00:32:42 +01:00

Fix Javascript busy loop when trying to delete tokens from an empty tokenizer

Summary:
Fixes T13147. In D19437, I changed this logic to support deleting the `""` (empty string) token, but `[].pop()` returns `undefined`, not `null`, if the list is empty and I didn't think to try deleting an empty input.

Fix the logic so we don't end up in a loop if the input is empty.

Test Plan:
  - In any browser, deleted all tokens in a tokenizer; then pressed delete again.
  - Before: tab hangs in an infinte loop.
  - After: smooth sailing.

Reviewers: amckinley, avivey

Reviewed By: avivey

Maniphest Tasks: T13147

Differential Revision: https://secure.phabricator.com/D19456
This commit is contained in:
epriestley 2018-06-01 13:05:46 -07:00
parent 2f6784ee1c
commit 31ee49b14d
2 changed files with 11 additions and 10 deletions

View file

@ -10,7 +10,7 @@ return array(
'conpherence.pkg.css' => 'e68cf1fa',
'conpherence.pkg.js' => '15191c65',
'core.pkg.css' => '8be474cc',
'core.pkg.js' => 'e452721e',
'core.pkg.js' => '2058ec09',
'differential.pkg.css' => '06dc617c',
'differential.pkg.js' => 'c2ca903a',
'diffusion.pkg.css' => 'a2d17c7d',
@ -259,7 +259,7 @@ return array(
'rsrc/externals/javelin/lib/__tests__/URI.js' => '1e45fda9',
'rsrc/externals/javelin/lib/__tests__/behavior.js' => '1ea62783',
'rsrc/externals/javelin/lib/behavior.js' => '61cbc29a',
'rsrc/externals/javelin/lib/control/tokenizer/Tokenizer.js' => 'dfaf006b',
'rsrc/externals/javelin/lib/control/tokenizer/Tokenizer.js' => 'bb6e5c16',
'rsrc/externals/javelin/lib/control/typeahead/Typeahead.js' => '70baed2f',
'rsrc/externals/javelin/lib/control/typeahead/normalizer/TypeaheadNormalizer.js' => '185bbd53',
'rsrc/externals/javelin/lib/control/typeahead/source/TypeaheadCompositeSource.js' => '503e17fd',
@ -710,7 +710,7 @@ return array(
'javelin-scrollbar' => '9065f639',
'javelin-sound' => '949c0fe5',
'javelin-stratcom' => '327f418a',
'javelin-tokenizer' => 'dfaf006b',
'javelin-tokenizer' => 'bb6e5c16',
'javelin-typeahead' => '70baed2f',
'javelin-typeahead-composite-source' => '503e17fd',
'javelin-typeahead-normalizer' => '185bbd53',
@ -1842,6 +1842,12 @@ return array(
'javelin-uri',
'phabricator-notification',
),
'bb6e5c16' => array(
'javelin-dom',
'javelin-util',
'javelin-stratcom',
'javelin-install',
),
'bcaccd64' => array(
'javelin-behavior',
'javelin-behavior-device',
@ -2019,12 +2025,6 @@ return array(
'phuix-icon-view',
'phabricator-prefab',
),
'dfaf006b' => array(
'javelin-dom',
'javelin-util',
'javelin-stratcom',
'javelin-install',
),
'e1d25dfb' => array(
'javelin-behavior',
'javelin-stratcom',

View file

@ -400,7 +400,8 @@ JX.install('Tokenizer', {
// this unusual token.
var tok;
while ((tok = this._tokens.pop()) !== null) {
while (this._tokens.length) {
tok = this._tokens.pop();
if (this._remove(tok, true)) {
break;
}