diff --git a/.github/workflows/coding-style.yml b/.github/workflows/coding-style.yml index 782447567..f1d060325 100644 --- a/.github/workflows/coding-style.yml +++ b/.github/workflows/coding-style.yml @@ -37,4 +37,4 @@ jobs: steps: - uses: actions/checkout@v4 - run: npm install - - run: npx eslint src/assets/netteForms.js + - run: npx eslint diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 2d1775889..aed90668b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php: ['8.1', '8.2', '8.3'] + php: ['8.1', '8.2', '8.3', '8.4'] fail-fast: false @@ -65,8 +65,6 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - run: npm install -g karma-cli + - run: npm install - working-directory: tests/netteForms - run: npm install - - working-directory: tests/netteForms - run: karma start + run: npx karma start karma.conf.cjs diff --git a/composer.json b/composer.json index 40c44dace..149e2941a 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ } ], "require": { - "php": "8.1 - 8.3", + "php": "8.1 - 8.4", "nette/component-model": "^3.1", "nette/http": "^3.3", "nette/utils": "^4.0.4" @@ -24,12 +24,12 @@ "nette/application": "^3.0", "nette/di": "^3.0", "nette/tester": "^2.5.2", - "latte/latte": "^2.10.2 || ^3.0.12", + "latte/latte": "^3.0.12", "tracy/tracy": "^2.9", "phpstan/phpstan-nette": "^1" }, "conflict": { - "latte/latte": ">=3.0.0 <3.0.12 || >=3.1" + "latte/latte": "<3.0.12" }, "suggest": { "ext-intl": "to use date/time controls" @@ -44,7 +44,7 @@ }, "extra": { "branch-alias": { - "dev-master": "3.2-dev" + "dev-master": "4.0-dev" } } } diff --git a/eslint.config.js b/eslint.config.js new file mode 100644 index 000000000..d4cc80561 --- /dev/null +++ b/eslint.config.js @@ -0,0 +1,48 @@ +import globals from 'globals'; +import pluginJs from '@eslint/js'; +import stylistic from '@stylistic/eslint-plugin'; + +export default [ + { + ignores: [ + '*/', '!src/', '!tests/', + '**/*.min.js', + ], + }, + + pluginJs.configs.recommended, + + stylistic.configs.customize({ + indent: 'tab', + braceStyle: '1tbs', + arrowParens: true, + semi: true, + jsx: false, + }), + + { + languageOptions: { + ecmaVersion: 2021, + globals: { + ...globals.browser, + ...globals.jasmine, + ...globals.amd, + ...globals.commonjs, + Nette: 'readable', + Tracy: 'writeable', + }, + }, + plugins: { + '@stylistic': stylistic, + }, + rules: { + '@stylistic/no-multiple-empty-lines': ['error', { max: 2, maxEOF: 0 }], + '@stylistic/new-parens': ['error', 'never'], + '@stylistic/padded-blocks': 'off', + 'func-style': ['error', 'declaration', { allowArrowFunctions: true }], + 'prefer-arrow-callback': 'error', + 'arrow-body-style': 'error', + 'no-var': 'error', + }, + }, +]; diff --git a/eslint.config.mjs b/eslint.config.mjs deleted file mode 100644 index 3e78d371e..000000000 --- a/eslint.config.mjs +++ /dev/null @@ -1,30 +0,0 @@ -import globals from 'globals'; -import pluginJs from '@eslint/js'; - -export default [ - pluginJs.configs.recommended, - { - ignores: ['**/*.min.js'], - }, - { - languageOptions: { - ecmaVersion: 2021, - globals: { - ...globals.browser, - 'Tracy': 'writeable', - 'define': 'readable', - 'module': 'readable', - }, - }, - rules: { - indent: ['error', 'tab'], - quotes: ['error', 'single'], - semi: ['error', 'always'], - 'func-style': ['error', 'declaration', {'allowArrowFunctions': true}], - 'prefer-arrow-callback': ['error'], - 'arrow-parens': ['error'], - 'arrow-spacing': ['error'], - 'no-var': ['error'], - }, - }, -]; diff --git a/package.json b/package.json index 9a73a127b..17ae86541 100644 --- a/package.json +++ b/package.json @@ -1,26 +1,14 @@ { - "name": "nette-forms", - "version": "3.4.1", - "description": "Client side script for Nette Forms Component", - "keywords": [ - "nette", - "validation", - "forms" - ], - "homepage": "https://nette.org", - "author": "David Grudl (https://davidgrudl.com)", - "license": "BSD-3-Clause", - "main": "src/assets/netteForms.js", - "files": [ - "src/assets" - ], - "repository": { - "type": "git", - "url": "git+https://github.com/nette/forms.git" - }, + "type": "module", "devDependencies": { - "@eslint/js": "^9.1.1", - "eslint": "^9.1.1", - "globals": "^15.1.0" + "@eslint/js": "^9.4.0", + "@stylistic/eslint-plugin": "^2.1.0", + "eslint": "^9.4.0", + "globals": "^15.3.0", + "jasmine": "^5.1.0", + "jasmine-core": "^5.1.1", + "karma": "^6.4.2", + "karma-chrome-launcher": "^3.2.0", + "karma-jasmine": "^5.1.0" } } diff --git a/readme.md b/readme.md index feca8b09a..45ffe2514 100644 --- a/readme.md +++ b/readme.md @@ -2,8 +2,8 @@ Nette Forms: greatly facilitates web forms ========================================== [![Downloads this Month](https://img.shields.io/packagist/dm/nette/forms.svg)](https://packagist.org/packages/nette/forms) -[![Tests](https://github.com/nette/forms/actions/workflows/tests.yml/badge.svg?branch=v3.2)](https://github.com/nette/forms/actions) -[![Coverage Status](https://coveralls.io/repos/github/nette/forms/badge.svg?branch=v3.2)](https://coveralls.io/github/nette/forms?branch=v3.2) +[![Tests](https://github.com/nette/forms/actions/workflows/tests.yml/badge.svg?branch=master)](https://github.com/nette/forms/actions) +[![Coverage Status](https://coveralls.io/repos/github/nette/forms/badge.svg?branch=master)](https://coveralls.io/github/nette/forms?branch=master) [![Latest Stable Version](https://poser.pugx.org/nette/forms/v/stable)](https://github.com/nette/forms/releases) [![License](https://img.shields.io/badge/license-New%20BSD-blue.svg)](https://github.com/nette/forms/blob/master/license.md) @@ -44,7 +44,7 @@ The recommended way to install is via Composer: composer require nette/forms ``` -It requires PHP version 8.1 and supports PHP up to 8.3. +It requires PHP version 8.1 and supports PHP up to 8.4. Client-side support can be installed with npm or yarn: diff --git a/src/Bridges/FormsLatte/FormMacros.php b/src/Bridges/FormsLatte/FormMacros.php deleted file mode 100644 index 18c889ad2..000000000 --- a/src/Bridges/FormsLatte/FormMacros.php +++ /dev/null @@ -1,330 +0,0 @@ -addMacro('form', [$me, 'macroForm'], 'echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd(array_pop($this->global->formsStack));'); - $me->addMacro('formContext', [$me, 'macroFormContext'], 'array_pop($this->global->formsStack);'); - $me->addMacro('formContainer', [$me, 'macroFormContainer'], 'array_pop($this->global->formsStack); $formContainer = end($this->global->formsStack)'); - $me->addMacro('label', [$me, 'macroLabel'], [$me, 'macroLabelEnd'], null, self::AUTO_EMPTY); - $me->addMacro('input', [$me, 'macroInput']); - $me->addMacro('name', [$me, 'macroName'], [$me, 'macroNameEnd'], [$me, 'macroNameAttr']); - $me->addMacro('inputError', [$me, 'macroInputError']); - $me->addMacro('formPrint', [$me, 'macroFormPrint']); - $me->addMacro('formClassPrint', [$me, 'macroFormPrint']); - } - - - /********************* macros ****************d*g**/ - - - /** - * {form ...} - */ - public function macroForm(MacroNode $node, PhpWriter $writer) - { - if ($node->modifiers) { - throw new CompileException('Modifiers are not allowed in ' . $node->getNotation()); - } - - if ($node->prefix) { - throw new CompileException('Did you mean
?'); - } - - $name = $node->tokenizer->fetchWord(); - if ($name == null) { // null or false - throw new CompileException('Missing form name in ' . $node->getNotation()); - } - - $node->replaced = true; - $node->tokenizer->reset(); - return $writer->write( - '$form = $this->global->formsStack[] = ' - . ($name[0] === '$' - ? 'is_object($ʟ_tmp = %node.word) ? $ʟ_tmp : $this->global->uiControl[$ʟ_tmp]' - : '$this->global->uiControl[%node.word]') - . ';' - . 'Nette\Bridges\FormsLatte\Runtime::initializeForm($form);' - . 'echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin($form, %node.array)' - . " /* line $node->startLine */;", - ); - } - - - /** - * {formContext ...} - */ - public function macroFormContext(MacroNode $node, PhpWriter $writer) - { - if ($node->modifiers) { - throw new CompileException('Modifiers are not allowed in ' . $node->getNotation()); - } - - if ($node->prefix) { - throw new CompileException('Did you mean ?'); - } - - $name = $node->tokenizer->fetchWord(); - if ($name == null) { // null or false - throw new CompileException('Missing form name in ' . $node->getNotation()); - } - - $node->tokenizer->reset(); - return $writer->write( - '$form = $this->global->formsStack[] = ' - . ($name[0] === '$' - ? 'is_object($ʟ_tmp = %node.word) ? $ʟ_tmp : $this->global->uiControl[$ʟ_tmp]' - : '$this->global->uiControl[%node.word]') - . " /* line $node->startLine */;", - ); - } - - - /** - * {formContainer ...} - */ - public function macroFormContainer(MacroNode $node, PhpWriter $writer) - { - if ($node->modifiers) { - throw new CompileException('Modifiers are not allowed in ' . $node->getNotation()); - } - - $name = $node->tokenizer->fetchWord(); - if ($name == null) { // null or false - throw new CompileException('Missing name in ' . $node->getNotation()); - } - - $node->tokenizer->reset(); - return $writer->write( - '$this->global->formsStack[] = $formContainer = ' - . ($name[0] === '$' - ? 'is_object($ʟ_tmp = %node.word) ? $ʟ_tmp : end($this->global->formsStack)[$ʟ_tmp]' - : 'end($this->global->formsStack)[%node.word]') - . " /* line $node->startLine */;", - ); - } - - - /** - * {label ...} - */ - public function macroLabel(MacroNode $node, PhpWriter $writer) - { - if ($node->modifiers) { - throw new CompileException('Modifiers are not allowed in ' . $node->getNotation()); - } - - $words = $node->tokenizer->fetchWords(); - if (!$words) { - throw new CompileException('Missing name in ' . $node->getNotation()); - } - - $node->replaced = true; - $name = array_shift($words); - return $writer->write( - ($name[0] === '$' - ? '$ʟ_input = is_object($ʟ_tmp = %0.word) ? $ʟ_tmp : end($this->global->formsStack)[$ʟ_tmp]; if ($ʟ_label = $ʟ_input' - : 'if ($ʟ_label = end($this->global->formsStack)[%0.word]' - ) - . '->%1.raw) echo $ʟ_label' - . ($node->tokenizer->isNext() ? '->addAttributes(%node.array)' : ''), - $name, - $words ? ('getLabelPart(' . implode(', ', array_map([$writer, 'formatWord'], $words)) . ')') : 'getLabel()', - ); - } - - - /** - * {/label} - */ - public function macroLabelEnd(MacroNode $node, PhpWriter $writer) - { - if ($node->content != null) { - $node->openingCode = rtrim($node->openingCode, '?> ') . '->startTag() ?>'; - return $writer->write('if ($ʟ_label) echo $ʟ_label->endTag()'); - } - } - - - /** - * {input ...} - */ - public function macroInput(MacroNode $node, PhpWriter $writer) - { - if ($node->modifiers) { - throw new CompileException('Modifiers are not allowed in ' . $node->getNotation()); - } - - $words = $node->tokenizer->fetchWords(); - if (!$words) { - throw new CompileException('Missing name in ' . $node->getNotation()); - } - - $node->replaced = true; - $name = array_shift($words); - return $writer->write( - ($name[0] === '$' - ? '$ʟ_input = $_input = is_object($ʟ_tmp = %word) ? $ʟ_tmp : end($this->global->formsStack)[$ʟ_tmp]; echo $ʟ_input' - : 'echo end($this->global->formsStack)[%word]') - . '->%raw' - . ($node->tokenizer->isNext() ? '->addAttributes(%node.array)' : '') - . " /* line $node->startLine */;", - $name, - $words ? 'getControlPart(' . implode(', ', array_map([$writer, 'formatWord'], $words)) . ')' : 'getControl()', - ); - } - - - /** - * , , - - - -
- - - - - - - - -
- - - - - - - - - - - - - - -
- - - -
- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - -
- -
- - -
- -
- - - - - - - - - - - - - - - \ No newline at end of file diff --git a/tests/Forms.Latte2/expected/FormMacros.forms.php b/tests/Forms.Latte2/expected/FormMacros.forms.php deleted file mode 100644 index dda078042..000000000 --- a/tests/Forms.Latte2/expected/FormMacros.forms.php +++ /dev/null @@ -1,297 +0,0 @@ -global->formsStack[] = $this->global->uiControl["myForm"]; - Nette\Bridges\FormsLatte\Runtime::initializeForm($form); - echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin($form, ['id' => 'myForm', 'class'=>"ajax"]) /* line 1 */; - echo "\n"; - $iterations = 0; - foreach (['id', 'username', 'select', 'area', 'send'] as $name) /* line 2 */ { - echo ' '; - $ʟ_input = is_object($ʟ_tmp = $name) ? $ʟ_tmp : end($this->global->formsStack)[$ʟ_tmp]; - if ($ʟ_label = $ʟ_input->getLabel()) echo $ʟ_label; - echo ' - '; - $ʟ_input = $_input = is_object($ʟ_tmp = $name) ? $ʟ_tmp : end($this->global->formsStack)[$ʟ_tmp]; - echo $ʟ_input->getControl()->addAttributes(['title' => 'Hello', 'size' => 10]) /* line 4 */; - echo ' - '; - echo LR\Filters::escapeHtmlText($ʟ_input->getError()) /* line 5 */; - echo ' - '; - $ʟ_input = is_object($ʟ_tmp = $name) ? $ʟ_tmp : end($this->global->formsStack)[$ʟ_tmp]; - echo LR\Filters::escapeHtmlText($ʟ_input->getError()) /* line 6 */; - echo ' - -
- - '; - $ʟ_input = is_object($ʟ_tmp = $form[$name]) ? $ʟ_tmp : end($this->global->formsStack)[$ʟ_tmp]; - if ($ʟ_label = $ʟ_input->getLabel()) echo $ʟ_label->addAttributes(['title' => 'hello'])->startTag(); - echo ' '; - $ʟ_input = $_input = is_object($ʟ_tmp = $form[$name]) ? $ʟ_tmp : end($this->global->formsStack)[$ʟ_tmp]; - echo $ʟ_input->getControl()->addAttributes(['title' => 'Hello', 'size' => 10]) /* line 10 */; - echo ' '; - if ($ʟ_label) echo $ʟ_label->endTag(); - echo ' - '; - $ʟ_input = is_object($ʟ_tmp = $form[$name]) ? $ʟ_tmp : end($this->global->formsStack)[$ʟ_tmp]; - echo LR\Filters::escapeHtmlText($ʟ_input->getError()) /* line 11 */; - echo "\n"; - $iterations++; - } - echo ' - '; - $ʟ_input = is_object($ʟ_tmp = $form['username']) ? $ʟ_tmp : end($this->global->formsStack)[$ʟ_tmp]; - if ($ʟ_label = $ʟ_input->getLabel()) echo $ʟ_label; - echo ' - - - global->formsStack)["username"]; - echo $ʟ_input->getControlPart()->addAttributes(['value' => null, 'type' => null, 'class' => null])->attributes() /* line 17 */; - echo '> - - global->formsStack)[$ʟ_tmp]; - echo $ʟ_input->getLabelPart()->attributes() /* line 19 */; - echo '> - global->formsStack)[$ʟ_tmp]; - echo $ʟ_input->getLabelPart()->attributes() /* line 20 */; - echo '>'; - echo $ʟ_input->getLabelPart()->getHtml() /* line 20 */; - echo ' - global->formsStack)[$ʟ_tmp]; - echo $ʟ_input->getControlPart()->attributes() /* line 21 */; - echo '> - - '; - if ($ʟ_label = end($this->global->formsStack)["my"]->getLabel()) echo $ʟ_label; - echo end($this->global->formsStack)["my"]->getControl() /* line 23 */; - echo "\n"; - echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd(array_pop($this->global->formsStack)); - echo ' - - -'; - $form = $this->global->formsStack[] = $this->global->uiControl["myForm"]; - Nette\Bridges\FormsLatte\Runtime::initializeForm($form); - echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin($form, []) /* line 27 */; - echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd(array_pop($this->global->formsStack)); - echo ' - -'; - $form = $this->global->formsStack[] = $this->global->uiControl["myForm"]; - Nette\Bridges\FormsLatte\Runtime::initializeForm($form); - echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin($form, []) /* line 29 */; - echo "\n"; - $iterations = 0; - foreach ($form['sex']->items as $key => $label) /* line 31 */ { - echo ' '; - if ($ʟ_label = end($this->global->formsStack)["sex"]->getLabelPart($key)) echo $ʟ_label->startTag(); - echo ' '; - echo end($this->global->formsStack)["sex"]->getControlPart($key) /* line 32 */; - echo ' '; - echo LR\Filters::escapeHtmlText($label) /* line 32 */; - if ($ʟ_label) echo $ʟ_label->endTag(); - echo ' - -'; - $iterations++; - } - echo 'global->formsStack)["sex"]; - echo $ʟ_input->getLabelPart()->attributes() /* line 35 */; - echo '> -global->formsStack)["sex"]; - echo $ʟ_input->getLabelPart()->attributes() /* line 36 */; - echo '>'; - echo $ʟ_input->getLabelPart()->getHtml() /* line 36 */; - echo ' - - - -'; - if ($ʟ_label = end($this->global->formsStack)["checkbox"]->getLabelPart("")) echo $ʟ_label->startTag(); - echo ' '; - echo end($this->global->formsStack)["checkbox"]->getControlPart("") /* line 41 */; - echo ' Label'; - if ($ʟ_label) echo $ʟ_label->endTag(); - echo ' - - -global->formsStack)["checkbox"]; - echo $ʟ_input->getLabelPart("")->attributes() /* line 44 */; - echo '>'; - echo $ʟ_input->getLabelPart()->getHtml() /* line 44 */; - echo ' - - - -'; - $iterations = 0; - foreach ($form['checklist']->items as $key => $label) /* line 49 */ { - echo ' '; - if ($ʟ_label = end($this->global->formsStack)["checklist"]->getLabelPart($key)) echo $ʟ_label->startTag(); - echo ' '; - echo end($this->global->formsStack)["checklist"]->getControlPart($key) /* line 50 */; - echo ' '; - echo LR\Filters::escapeHtmlText($label) /* line 50 */; - if ($ʟ_label) echo $ʟ_label->endTag(); - echo ' - global->formsStack)["checklist"]; - echo $ʟ_input->getLabelPart($key)->attributes() /* line 51 */; - echo '> global->formsStack)["checklist"]; - echo $ʟ_input->getControlPart($key)->addAttributes(['title' => null])->attributes() /* line 51 */; - echo '> -'; - $iterations++; - } - echo 'global->formsStack)["checklist"]; - echo $ʟ_input->getLabelPart()->attributes() /* line 53 */; - echo '> -global->formsStack)["checklist"]; - echo $ʟ_input->getLabelPart()->attributes() /* line 54 */; - echo '>'; - echo $ʟ_input->getLabelPart()->getHtml() /* line 54 */; - echo ' - - - -'; - $form = $this->global->formsStack[] = $this->global->uiControl["myForm"] /* line 58 */; - Nette\Bridges\FormsLatte\Runtime::initializeForm($form); - if (1) /* line 58 */ { - echo '
global->formsStack), ['id' => null, 'class' => null], false); - echo '> - global->formsStack)["username"]; - echo $ʟ_input->getControlPart()->attributes() /* line 59 */; - echo '> -'; - echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd(array_pop($this->global->formsStack), false) /* line 58 */; - echo ' -'; - } - echo ' - -'; - $form = $this->global->formsStack[] = $this->global->uiControl["myForm"] /* line 63 */; - Nette\Bridges\FormsLatte\Runtime::initializeForm($form); - echo 'global->formsStack), ['class' => null], false); - echo '> - global->formsStack)["username"]; - echo $ʟ_input->getControlPart()->addAttributes(['class' => null])->attributes() /* line 64 */; - echo ($ʟ_tmp = array_filter(['nclass'])) ? ' class="' . LR\Filters::escapeHtmlAttr(implode(" ", array_unique($ʟ_tmp))) . '"' : "" /* line 64 */; - echo '> -'; - echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd(array_pop($this->global->formsStack), false) /* line 63 */; - echo ' - - -'; - $form = $this->global->formsStack[] = is_object($ʟ_tmp = $this->global->uiControl['myForm']) ? $ʟ_tmp : $this->global->uiControl[$ʟ_tmp] /* line 68 */; - Nette\Bridges\FormsLatte\Runtime::initializeForm($form); - echo 'global->formsStack), [], false); - echo '> - global->formsStack)["username"]; - echo $ʟ_input->getControlPart()->attributes() /* line 69 */; - echo '> -'; - echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd(array_pop($this->global->formsStack), false) /* line 68 */; - echo ' - - -global->formsStack)["select"]; - echo $ʟ_input->getControlPart()->attributes() /* line 73 */; - echo '>'; - echo $ʟ_input->getControl()->getHtml() /* line 73 */; - echo ' - - - - - -global->formsStack)["select"]; - echo $ʟ_input->getControlPart()->attributes() /* line 79 */; - echo '>'; - echo $ʟ_input->getControl()->getHtml() /* line 79 */; - echo ' -'; - echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd(array_pop($this->global->formsStack)); - echo ' - - -'; - $form = $this->global->formsStack[] = $this->global->uiControl["myForm"] /* line 83 */; - echo 'global->formsStack)["sex"]; - echo $ʟ_input->getLabelPart()->attributes() /* line 84 */; - echo '>'; - echo $ʟ_input->getLabelPart()->getHtml() /* line 84 */; - echo ' -global->formsStack)["username"]; - echo $ʟ_input->getControlPart()->attributes() /* line 85 */; - echo '> -'; - array_pop($this->global->formsStack); -%A% diff --git a/tests/Forms.Latte2/expected/FormMacros.get.html b/tests/Forms.Latte2/expected/FormMacros.get.html deleted file mode 100644 index e37282817..000000000 --- a/tests/Forms.Latte2/expected/FormMacros.get.html +++ /dev/null @@ -1,5 +0,0 @@ -
- - -
-
\ No newline at end of file diff --git a/tests/Forms.Latte2/expected/FormMacros.get.php b/tests/Forms.Latte2/expected/FormMacros.get.php deleted file mode 100644 index ae17372cd..000000000 --- a/tests/Forms.Latte2/expected/FormMacros.get.php +++ /dev/null @@ -1,19 +0,0 @@ -global->formsStack[] = $this->global->uiControl["myForm"]; - Nette\Bridges\FormsLatte\Runtime::initializeForm($form); - echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin($form, []) /* line 1 */; - echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd(array_pop($this->global->formsStack)); - echo ' - -'; - $form = $this->global->formsStack[] = $this->global->uiControl["myForm"] /* line 3 */; - Nette\Bridges\FormsLatte\Runtime::initializeForm($form); - echo 'global->formsStack), [], false); - echo '> -'; - echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd(array_pop($this->global->formsStack), false) /* line 3 */; - echo ' -'; -%A% diff --git a/tests/Forms.Latte2/templates/forms.button.latte b/tests/Forms.Latte2/templates/forms.button.latte deleted file mode 100644 index 8e9969b37..000000000 --- a/tests/Forms.Latte2/templates/forms.button.latte +++ /dev/null @@ -1,9 +0,0 @@ -
- - - - -
global)->getControlPart())->attributes() /* line %d% */; + echo ($ʟ_elem = $this->global->forms->item('send')->getControlPart())->attributes() /* line %d% */; echo '> global)->getControlPart())->attributes() /* line %d% */; + echo ($ʟ_elem = $this->global->forms->item('send')->getControlPart())->attributes() /* line %d% */; echo '>'; echo LR\Filters::escapeHtmlText($ʟ_elem->value) /* line %d% */; echo ' '; - echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd(end($this->global->formsStack), false) /* line %d% */; + echo $this->global->forms->renderFormEnd(false) /* line %d% */; echo ' '; - array_pop($this->global->formsStack); + $this->global->forms->end(); %A% diff --git a/tests/Forms.Latte3/expected/forms.formContainer.php b/tests/Forms.Latte3/expected/forms.formContainer.php index 893cc8e3a..6bd65b4e0 100644 --- a/tests/Forms.Latte3/expected/forms.formContainer.php +++ b/tests/Forms.Latte3/expected/forms.formContainer.php @@ -1,46 +1,45 @@ global->formsStack[] = $this->global->uiControl['myForm'] /* line %d% */; - Nette\Bridges\FormsLatte\Runtime::initializeForm($form); - echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin($form, []) /* line %d% */; + $this->global->forms->begin($form = $this->global->uiControl['myForm']) /* line %d% */; + echo $this->global->forms->renderFormBegin([]) /* line %d% */; echo ' '; - $this->global->formsStack[] = $formContainer = Nette\Bridges\FormsLatte\Runtime::item('cont1', $this->global) /* line %d% */; + $this->global->forms->begin($formContainer = $this->global->forms->item('cont1')) /* line %d% */; echo ' '; - array_pop($this->global->formsStack); - $formContainer = end($this->global->formsStack); + $this->global->forms->end(); + $formContainer = $this->global->forms->current(); - $this->global->formsStack[] = $formContainer = Nette\Bridges\FormsLatte\Runtime::item('items', $this->global) /* line %d% */; + $this->global->forms->begin($formContainer = $this->global->forms->item('items')) /* line %d% */; echo ' '; - array_pop($this->global->formsStack); - $formContainer = end($this->global->formsStack); + $this->global->forms->end(); + $formContainer = $this->global->forms->current(); echo '
'; - echo ($ʟ_label = Nette\Bridges\FormsLatte\Runtime::item('input1', $this->global)->getLabel()) /* line %d% */; + echo ($ʟ_label = $this->global->forms->item('input1')->getLabel()) /* line %d% */; echo ' '; - echo Nette\Bridges\FormsLatte\Runtime::item('input1', $this->global)->getControl() /* line %d% */; + echo $this->global->forms->item('input1')->getControl() /* line %d% */; echo '
'; - echo ($ʟ_label = Nette\Bridges\FormsLatte\Runtime::item('input2', $this->global)->getLabel()) /* line %d% */; + echo ($ʟ_label = $this->global->forms->item('input2')->getLabel()) /* line %d% */; echo ' '; - echo Nette\Bridges\FormsLatte\Runtime::item('input2', $this->global)->getControl() /* line %d% */; + echo $this->global->forms->item('input2')->getControl() /* line %d% */; echo '
'; - echo ($ʟ_label = Nette\Bridges\FormsLatte\Runtime::item('input3', $this->global)->getLabel()) /* line %d% */; + echo ($ʟ_label = $this->global->forms->item('input3')->getLabel()) /* line %d% */; echo ' '; - echo Nette\Bridges\FormsLatte\Runtime::item('input3', $this->global)->getControl() /* line %d% */; + echo $this->global->forms->item('input3')->getControl() /* line %d% */; echo '
Checkboxes '; - $this->global->formsStack[] = $formContainer = Nette\Bridges\FormsLatte\Runtime::item('cont2', $this->global) /* line %d% */; + $this->global->forms->begin($formContainer = $this->global->forms->item('cont2')) /* line %d% */; echo '
    '; foreach ($formContainer->controls as $name => $field) /* line %d% */ { echo '
  1. '; - echo Nette\Bridges\FormsLatte\Runtime::item($field, $this->global)->getControl() /* line %d% */; + echo $this->global->forms->item($field)->getControl() /* line %d% */; echo '
  2. '; @@ -48,24 +47,24 @@ echo '
'; - array_pop($this->global->formsStack); - $formContainer = end($this->global->formsStack); + $this->global->forms->end(); + $formContainer = $this->global->forms->current(); echo '
'; - echo ($ʟ_label = Nette\Bridges\FormsLatte\Runtime::item('input7', $this->global)->getLabel()) /* line %d% */; + echo ($ʟ_label = $this->global->forms->item('input7')->getLabel()) /* line %d% */; echo ' '; - echo Nette\Bridges\FormsLatte\Runtime::item('input7', $this->global)->getControl() /* line %d% */; + echo $this->global->forms->item('input7')->getControl() /* line %d% */; echo '
Items @@ -73,12 +72,12 @@ $items = [1, 2, 3] /* line %d% */; foreach ($items as $item) /* line %d% */ { if (!isset($formContainer[$item])) /* line %d% */ continue; - $this->global->formsStack[] = $formContainer = Nette\Bridges\FormsLatte\Runtime::item($item, $this->global) /* line %d% */; + $this->global->forms->begin($formContainer = $this->global->forms->item($item)) /* line %d% */; echo ' '; - echo Nette\Bridges\FormsLatte\Runtime::item('input', $this->global)->getControl() /* line %d% */; + echo $this->global->forms->item('input')->getControl() /* line %d% */; echo "\n"; - array_pop($this->global->formsStack); - $formContainer = end($this->global->formsStack); + $this->global->forms->end(); + $formContainer = $this->global->forms->current(); } @@ -86,18 +85,19 @@ echo '
'; - echo ($ʟ_label = Nette\Bridges\FormsLatte\Runtime::item('input8', $this->global)->getLabel()) /* line %d% */; + echo ($ʟ_label = $this->global->forms->item('input8')->getLabel()) /* line %d% */; echo ' '; - echo Nette\Bridges\FormsLatte\Runtime::item('input8', $this->global)->getControl() /* line %d% */; + echo $this->global->forms->item('input8')->getControl() /* line %d% */; echo '
'; - echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd(array_pop($this->global->formsStack)) /* line %d% */; -%A% + echo $this->global->forms->renderFormEnd() /* line %d% */; + $this->global->forms->end(); +%A% \ No newline at end of file diff --git a/tests/Forms.Latte3/expected/forms.get.php b/tests/Forms.Latte3/expected/forms.get.php index 25af74d41..0fd2c1eda 100644 --- a/tests/Forms.Latte3/expected/forms.get.php +++ b/tests/Forms.Latte3/expected/forms.get.php @@ -1,21 +1,20 @@ global->formsStack[] = $this->global->uiControl['myForm'] /* line %d% */; - Nette\Bridges\FormsLatte\Runtime::initializeForm($form); - echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin($form, []) /* line %d% */; - echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd(array_pop($this->global->formsStack)) /* line %d% */; + $this->global->forms->begin($form = $this->global->uiControl['myForm']) /* line %d% */; + echo $this->global->forms->renderFormBegin([]) /* line %d% */; + echo $this->global->forms->renderFormEnd() /* line %d% */; + $this->global->forms->end(); echo ' '; - $form = $this->global->formsStack[] = $this->global->uiControl['myForm'] /* line %d% */; - Nette\Bridges\FormsLatte\Runtime::initializeForm($form); + $this->global->forms->begin($form = $this->global->uiControl['myForm']) /* line %d% */; echo 'global->formsStack), [], false) /* line %d% */; + echo $this->global->forms->renderFormBegin([], false) /* line %d% */; echo '> '; - echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd(end($this->global->formsStack), false) /* line %d% */; + echo $this->global->forms->renderFormEnd(false) /* line %d% */; echo ' '; - array_pop($this->global->formsStack); -%A% + $this->global->forms->end(); +%A% \ No newline at end of file diff --git a/tests/Forms.Latte3/expected/forms.html b/tests/Forms.Latte3/expected/forms.html index 8bc003240..30672133c 100644 --- a/tests/Forms.Latte3/expected/forms.html +++ b/tests/Forms.Latte3/expected/forms.html @@ -8,12 +8,12 @@ - + error
- + error @@ -43,11 +43,11 @@ - + - + @@ -89,17 +89,17 @@
- +
- +
- +
@@ -111,9 +111,3 @@ - - - - - - \ No newline at end of file diff --git a/tests/Forms.Latte3/expected/forms.php b/tests/Forms.Latte3/expected/forms.php index d43dfec50..1fea76c4f 100644 --- a/tests/Forms.Latte3/expected/forms.php +++ b/tests/Forms.Latte3/expected/forms.php @@ -1,97 +1,96 @@ global->formsStack[] = $this->global->uiControl['myForm'] /* line %d% */; - Nette\Bridges\FormsLatte\Runtime::initializeForm($form); - echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin($form, ['id' => 'myForm', 'class' => 'ajax']) /* line %d% */; + $this->global->forms->begin($form = $this->global->uiControl['myForm']) /* line %d% */; + echo $this->global->forms->renderFormBegin(['id' => 'myForm', 'class' => 'ajax']) /* line %d% */; echo "\n"; foreach (['id', 'username', 'select', 'area', 'send'] as $name) /* line %d% */ { echo ' '; - echo ($ʟ_label = Nette\Bridges\FormsLatte\Runtime::item($name, $this->global)->getLabel()) /* line %d% */; + echo ($ʟ_label = $this->global->forms->item($name)->getLabel()) /* line %d% */; echo ' '; - echo Nette\Bridges\FormsLatte\Runtime::item($name, $this->global)->getControl()->addAttributes(['title' => 'Hello', 'size' => 10]) /* line %d% */; + echo $this->global->forms->item($name)->getControl()->addAttributes(['title' => 'Hello', 'size' => 10]) /* line %d% */; echo ' '; - echo LR\Filters::escapeHtmlText(Nette\Bridges\FormsLatte\Runtime::item($name, $this->global)->getError()) /* line %d% */; + echo LR\Filters::escapeHtmlText($this->global->forms->item($name)->getError()) /* line %d% */; echo '
'; - echo ($ʟ_label = Nette\Bridges\FormsLatte\Runtime::item($form[$name], $this->global)->getLabel())?->addAttributes(['title' => 'hello'])?->startTag() /* line %d% */; + echo ($ʟ_label = $this->global->forms->item($form[$name])->getLabel())?->addAttributes(['title' => 'hello'])?->startTag() /* line %d% */; echo ' '; - echo Nette\Bridges\FormsLatte\Runtime::item($form[$name], $this->global)->getControl()->addAttributes(['title' => 'Hello', 'size' => 10]) /* line %d% */; + echo $this->global->forms->item($form[$name])->getControl()->addAttributes(['title' => 'Hello', 'size' => 10]) /* line %d% */; echo ' '; echo $ʟ_label?->endTag() /* line %d% */; echo ' '; - echo LR\Filters::escapeHtmlText(Nette\Bridges\FormsLatte\Runtime::item($form[$name], $this->global)->getError()) /* line %d% */; + echo LR\Filters::escapeHtmlText($this->global->forms->item($form[$name])->getError()) /* line %d% */; echo "\n"; } echo ' '; - echo ($ʟ_label = Nette\Bridges\FormsLatte\Runtime::item($form['username'], $this->global)->getLabel()) /* line %d% */; + echo ($ʟ_label = $this->global->forms->item($form['username'])->getLabel()) /* line %d% */; echo ' global)->getLabelPart())->addAttributes(['title' => null])->attributes() /* line %d% */; + echo ($ʟ_elem = $this->global->forms->item('username')->getLabelPart())->addAttributes(['title' => null])->attributes() /* line %d% */; echo ' title=hello>Name global)->getControlPart())->addAttributes(['value' => null, 'type' => null, 'class' => null])->attributes() /* line %d% */; + echo ($ʟ_elem = $this->global->forms->item('username')->getControlPart())->addAttributes(['value' => null, 'type' => null, 'class' => null])->attributes() /* line %d% */; echo '> global)->getLabelPart())->attributes() /* line %d% */; + echo ($ʟ_elem = $this->global->forms->item($form['username'])->getLabelPart())->attributes() /* line %d% */; echo '> global)->getLabelPart())->attributes() /* line %d% */; + echo ($ʟ_elem = $this->global->forms->item($form['username'])->getLabelPart())->attributes() /* line %d% */; echo '>'; echo $ʟ_elem->getHtml() /* line %d% */; echo ' global)->getControlPart())->attributes() /* line %d% */; + echo ($ʟ_elem = $this->global->forms->item($form['username'])->getControlPart())->attributes() /* line %d% */; echo '> '; - echo ($ʟ_label = Nette\Bridges\FormsLatte\Runtime::item('my', $this->global)->getLabel()) /* line %d% */; - echo Nette\Bridges\FormsLatte\Runtime::item('my', $this->global)->getControl() /* line %d% */; + echo ($ʟ_label = $this->global->forms->item('my')->getLabel()) /* line %d% */; + echo $this->global->forms->item('my')->getControl() /* line %d% */; echo "\n"; - echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd(array_pop($this->global->formsStack)) /* line %d% */; + echo $this->global->forms->renderFormEnd() /* line %d% */; + $this->global->forms->end(); echo ' '; - $form = $this->global->formsStack[] = $this->global->uiControl['myForm'] /* line %d% */; - Nette\Bridges\FormsLatte\Runtime::initializeForm($form); - echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin($form, []) /* line %d% */; - echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd(array_pop($this->global->formsStack)) /* line %d% */; + $this->global->forms->begin($form = $this->global->uiControl['myForm']) /* line %d% */; + echo $this->global->forms->renderFormBegin([]) /* line %d% */; + echo $this->global->forms->renderFormEnd() /* line %d% */; + $this->global->forms->end(); echo ' '; - $form = $this->global->formsStack[] = $this->global->uiControl['myForm'] /* line %d% */; - Nette\Bridges\FormsLatte\Runtime::initializeForm($form); - echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin($form, []) /* line %d% */; + $this->global->forms->begin($form = $this->global->uiControl['myForm']) /* line %d% */; + echo $this->global->forms->renderFormBegin([]) /* line %d% */; echo "\n"; foreach ($form['sex']->items as $key => $label) /* line %d% */ { echo ' '; - echo ($ʟ_label = Nette\Bridges\FormsLatte\Runtime::item('sex', $this->global)->getLabelPart($key))?->startTag() /* line %d% */; + echo ($ʟ_label = $this->global->forms->item('sex')->getLabelPart($key))?->startTag() /* line %d% */; echo ' '; - echo Nette\Bridges\FormsLatte\Runtime::item('sex', $this->global)->getControlPart($key) /* line %d% */; + echo $this->global->forms->item('sex')->getControlPart($key) /* line %d% */; echo ' '; echo LR\Filters::escapeHtmlText($label) /* line %d% */; echo $ʟ_label?->endTag() /* line %d% */; echo ' global)->getLabelPart($key))->addAttributes(['title' => null])->attributes() /* line %d% */; + echo ($ʟ_elem = $this->global->forms->item('sex')->getLabelPart($key))->addAttributes(['title' => null])->attributes() /* line %d% */; echo ' title=hello> global)->getControlPart($key))->attributes() /* line %d% */; + echo ($ʟ_elem = $this->global->forms->item('sex')->getControlPart($key))->attributes() /* line %d% */; echo '> global)->getLabelPart($key))->addAttributes(['title' => null])->attributes() /* line %d% */; + echo ($ʟ_elem = $this->global->forms->item('sex')->getLabelPart($key))->addAttributes(['title' => null])->attributes() /* line %d% */; echo ' title=hello>'; echo $ʟ_elem->getHtml() /* line %d% */; echo ' @@ -100,47 +99,47 @@ } echo 'global)->getLabelPart())->attributes() /* line %d% */; + echo ($ʟ_elem = $this->global->forms->item('sex')->getLabelPart())->attributes() /* line %d% */; echo '> global)->getLabelPart())->attributes() /* line %d% */; + echo ($ʟ_elem = $this->global->forms->item('sex')->getLabelPart())->attributes() /* line %d% */; echo '>'; echo $ʟ_elem->getHtml() /* line %d% */; echo ' global)->getLabelPart())->addAttributes(['title' => null])->attributes() /* line %d% */; + echo ($ʟ_elem = $this->global->forms->item('sex')->getLabelPart())->addAttributes(['title' => null])->attributes() /* line %d% */; echo ' title="hello">'; echo $ʟ_elem->getHtml() /* line %d% */; echo ' global)->getControlPart("{$key}"))->attributes() /* line %d% */; + echo ($ʟ_elem = $this->global->forms->item($form['sex'])->getControlPart("{$key}"))->attributes() /* line %d% */; echo '> '; - echo ($ʟ_label = Nette\Bridges\FormsLatte\Runtime::item('checkbox', $this->global)->getLabelPart(''))?->startTag() /* line %d% */; + echo ($ʟ_label = $this->global->forms->item('checkbox')->getLabelPart(''))?->startTag() /* line %d% */; echo ' '; - echo Nette\Bridges\FormsLatte\Runtime::item('checkbox', $this->global)->getControlPart('') /* line %d% */; + echo $this->global->forms->item('checkbox')->getControlPart('') /* line %d% */; echo ' Label'; echo $ʟ_label?->endTag() /* line %d% */; echo ' global)->getLabelPart(''))->addAttributes(['title' => null])->attributes() /* line %d% */; + echo ($ʟ_elem = $this->global->forms->item('checkbox')->getLabelPart(''))->addAttributes(['title' => null])->attributes() /* line %d% */; echo ' title=hello> global)->getControlPart(''))->attributes() /* line %d% */; + echo ($ʟ_elem = $this->global->forms->item('checkbox')->getControlPart(''))->attributes() /* line %d% */; echo '> global)->getLabelPart())->addAttributes(['title' => null])->attributes() /* line %d% */; + echo ($ʟ_elem = $this->global->forms->item('checkbox')->getLabelPart())->addAttributes(['title' => null])->attributes() /* line %d% */; echo ' title=hello> global)->getControlPart())->attributes() /* line %d% */; + echo ($ʟ_elem = $this->global->forms->item('checkbox')->getControlPart())->attributes() /* line %d% */; echo '> global)->getLabelPart(''))->attributes() /* line %d% */; + echo ($ʟ_elem = $this->global->forms->item('checkbox')->getLabelPart(''))->attributes() /* line %d% */; echo '>'; echo $ʟ_elem->getHtml() /* line %d% */; echo ' global)->getLabelPart())->addAttributes(['title' => null])->attributes() /* line %d% */; + echo ($ʟ_elem = $this->global->forms->item('checkbox')->getLabelPart())->addAttributes(['title' => null])->attributes() /* line %d% */; echo ' title=hello>'; echo $ʟ_elem->getHtml() /* line %d% */; echo ' @@ -149,20 +148,20 @@ '; foreach ($form['checklist']->items as $key => $label) /* line %d% */ { echo ' '; - echo ($ʟ_label = Nette\Bridges\FormsLatte\Runtime::item('checklist', $this->global)->getLabelPart($key))?->startTag() /* line %d% */; + echo ($ʟ_label = $this->global->forms->item('checklist')->getLabelPart($key))?->startTag() /* line %d% */; echo ' '; - echo Nette\Bridges\FormsLatte\Runtime::item('checklist', $this->global)->getControlPart($key) /* line %d% */; + echo $this->global->forms->item('checklist')->getControlPart($key) /* line %d% */; echo ' '; echo LR\Filters::escapeHtmlText($label) /* line %d% */; echo $ʟ_label?->endTag() /* line %d% */; echo ' global)->getLabelPart($key))->attributes() /* line %d% */; + echo ($ʟ_elem = $this->global->forms->item('checklist')->getLabelPart($key))->attributes() /* line %d% */; echo '> global)->getControlPart($key))->addAttributes(['title' => null])->attributes() /* line %d% */; + echo ($ʟ_elem = $this->global->forms->item('checklist')->getControlPart($key))->addAttributes(['title' => null])->attributes() /* line %d% */; echo ' title=hello> global)->getLabelPart($key))->attributes() /* line %d% */; + echo ($ʟ_elem = $this->global->forms->item('checklist')->getLabelPart($key))->attributes() /* line %d% */; echo '>'; echo $ʟ_elem->getHtml() /* line %d% */; echo ' @@ -171,15 +170,15 @@ } echo 'global)->getLabelPart())->attributes() /* line %d% */; + echo ($ʟ_elem = $this->global->forms->item('checklist')->getLabelPart())->attributes() /* line %d% */; echo '> global)->getLabelPart())->attributes() /* line %d% */; + echo ($ʟ_elem = $this->global->forms->item('checklist')->getLabelPart())->attributes() /* line %d% */; echo '>'; echo $ʟ_elem->getHtml() /* line %d% */; echo ' global)->getLabelPart())->addAttributes(['title' => null])->attributes() /* line %d% */; + echo ($ʟ_elem = $this->global->forms->item('checklist')->getLabelPart())->addAttributes(['title' => null])->attributes() /* line %d% */; echo ' title="hello">'; echo $ʟ_elem->getHtml() /* line %d% */; echo ' @@ -187,65 +186,62 @@ '; if (1) /* line %d% */ { - $form = $this->global->formsStack[] = $this->global->uiControl['myForm'] /* line %d% */; - Nette\Bridges\FormsLatte\Runtime::initializeForm($form); + $this->global->forms->begin($form = $this->global->uiControl['myForm']) /* line %d% */; echo 'global->formsStack), ['id' => null, 'class' => null], false) /* line %d% */; + echo $this->global->forms->renderFormBegin(['id' => null, 'class' => null], false) /* line %d% */; echo ' id="myForm" class="ajax"> global)->getControlPart())->attributes() /* line %d% */; + echo ($ʟ_elem = $this->global->forms->item('username')->getControlPart())->attributes() /* line %d% */; echo '> '; - echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd(end($this->global->formsStack), false) /* line %d% */; + echo $this->global->forms->renderFormEnd(false) /* line %d% */; echo ' '; - array_pop($this->global->formsStack); + $this->global->forms->end(); } echo ' '; - $form = $this->global->formsStack[] = $this->global->uiControl['myForm'] /* line %d% */; - Nette\Bridges\FormsLatte\Runtime::initializeForm($form); + $this->global->forms->begin($form = $this->global->uiControl['myForm']) /* line %d% */; echo 'global->formsStack), ['class' => null], false) /* line %d% */; + echo $this->global->forms->renderFormBegin(['class' => null], false) /* line %d% */; echo ($ʟ_tmp = array_filter(['nclass'])) ? ' class="' . LR\Filters::escapeHtmlAttr(implode(" ", array_unique($ʟ_tmp))) . '"' : "" /* line %d% */; echo '> global)->getControlPart())->addAttributes(['class' => null])->attributes() /* line %d% */; + echo ($ʟ_elem = $this->global->forms->item('username')->getControlPart())->addAttributes(['class' => null])->attributes() /* line %d% */; echo ($ʟ_tmp = array_filter(['nclass'])) ? ' class="' . LR\Filters::escapeHtmlAttr(implode(" ", array_unique($ʟ_tmp))) . '"' : "" /* line %d% */; echo '> '; - echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd(end($this->global->formsStack), false) /* line %d% */; + echo $this->global->forms->renderFormEnd(false) /* line %d% */; echo ' '; - array_pop($this->global->formsStack); + $this->global->forms->end(); echo ' '; - $form = $this->global->formsStack[] = is_object($ʟ_tmp = $this->global->uiControl['myForm']) ? $ʟ_tmp : $this->global->uiControl[$ʟ_tmp] /* line %d% */; - Nette\Bridges\FormsLatte\Runtime::initializeForm($form); + $this->global->forms->begin($form = (is_object($ʟ_tmp = $this->global->uiControl['myForm']) ? $ʟ_tmp : $this->global->uiControl[$ʟ_tmp])) /* line %d% */; echo 'global->formsStack), [], false) /* line %d% */; + echo $this->global->forms->renderFormBegin([], false) /* line %d% */; echo '> global)->getControlPart())->attributes() /* line %d% */; + echo ($ʟ_elem = $this->global->forms->item('username')->getControlPart())->attributes() /* line %d% */; echo '> '; - echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd(end($this->global->formsStack), false) /* line %d% */; + echo $this->global->forms->renderFormEnd(false) /* line %d% */; echo ' '; - array_pop($this->global->formsStack); + $this->global->forms->end(); echo ' global)->getControlPart())->attributes() /* line %d% */; + echo ($ʟ_elem = $this->global->forms->item('select')->getControlPart())->attributes() /* line %d% */; echo '>'; echo $ʟ_elem->getHtml() /* line %d% */; echo ' global)->getControlPart())->addAttributes(['title' => null])->attributes() /* line %d% */; + echo ($ʟ_elem = $this->global->forms->item('area')->getControlPart())->addAttributes(['title' => null])->attributes() /* line %d% */; echo ' title="'; echo LR\Filters::escapeHtmlAttr(10) /* line %d% */; echo '">'; @@ -254,28 +250,11 @@ global)->getControlPart())->attributes() /* line %d% */; + echo ($ʟ_elem = $this->global->forms->item('select')->getControlPart())->attributes() /* line %d% */; echo '>'; echo $ʟ_elem->getHtml() /* line %d% */; echo ' '; - echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd(array_pop($this->global->formsStack)) /* line %d% */; - - echo ' - - -'; - $form = $this->global->formsStack[] = $this->global->uiControl['myForm'] /* line %d% */; - Nette\Bridges\FormsLatte\Runtime::initializeForm($form); - echo ' -global)->getLabelPart())->attributes() /* line %d% */; - echo '>'; - echo $ʟ_elem->getHtml() /* line %d% */; - echo ' -global)->getControlPart())->attributes() /* line %d% */; - echo '> -'; - array_pop($this->global->formsStack) /* line %d% */; + echo $this->global->forms->renderFormEnd() /* line %d% */; + $this->global->forms->end(); %A% diff --git a/tests/Forms.Latte3/forms.button.phpt b/tests/Forms.Latte3/forms.button.phpt index 136f44bd3..6e8aa59c1 100644 --- a/tests/Forms.Latte3/forms.button.phpt +++ b/tests/Forms.Latte3/forms.button.phpt @@ -8,10 +8,6 @@ use Tester\Assert; require __DIR__ . '/../bootstrap.php'; -if (version_compare(Latte\Engine::VERSION, '3', '<')) { - Tester\Environment::skip('Test for Latte 3'); -} - $form = new Form; $form->addSubmit('send', 'Sign in'); diff --git a/tests/Forms.Latte3/forms.error.phpt b/tests/Forms.Latte3/forms.error.phpt index b18a61a4a..f4a9c7dbf 100644 --- a/tests/Forms.Latte3/forms.error.phpt +++ b/tests/Forms.Latte3/forms.error.phpt @@ -7,10 +7,6 @@ use Tester\Assert; require __DIR__ . '/../bootstrap.php'; -if (version_compare(Latte\Engine::VERSION, '3', '<')) { - Tester\Environment::skip('Test for Latte 3'); -} - $latte = new Latte\Engine; $latte->setLoader(new Latte\Loaders\StringLoader); diff --git a/tests/Forms.Latte3/forms.formContainer.phpt b/tests/Forms.Latte3/forms.formContainer.phpt index 51eb27da6..f22b3baae 100644 --- a/tests/Forms.Latte3/forms.formContainer.phpt +++ b/tests/Forms.Latte3/forms.formContainer.phpt @@ -8,10 +8,6 @@ use Tester\Assert; require __DIR__ . '/../bootstrap.php'; -if (version_compare(Latte\Engine::VERSION, '3', '<')) { - Tester\Environment::skip('Test for Latte 3'); -} - $form = new Form; $form->addText('input1', 'Input 1'); diff --git a/tests/Forms.Latte3/forms.get.phpt b/tests/Forms.Latte3/forms.get.phpt index e1dada478..a2fa0ffd8 100644 --- a/tests/Forms.Latte3/forms.get.phpt +++ b/tests/Forms.Latte3/forms.get.phpt @@ -8,10 +8,6 @@ use Tester\Assert; require __DIR__ . '/../bootstrap.php'; -if (version_compare(Latte\Engine::VERSION, '3', '<')) { - Tester\Environment::skip('Test for Latte 3'); -} - $form = new Form; $form->setMethod('get'); diff --git a/tests/Forms.Latte3/forms.phpt b/tests/Forms.Latte3/forms.phpt index 0cc769add..c7724fac7 100644 --- a/tests/Forms.Latte3/forms.phpt +++ b/tests/Forms.Latte3/forms.phpt @@ -8,10 +8,6 @@ use Tester\Assert; require __DIR__ . '/../bootstrap.php'; -if (version_compare(Latte\Engine::VERSION, '3', '<')) { - Tester\Environment::skip('Test for Latte 3'); -} - class MyControl extends Nette\Forms\Controls\BaseControl { diff --git a/tests/Forms.Latte3/n-name.form.phpt b/tests/Forms.Latte3/n-name.form.phpt index b152db0da..7dd33928f 100644 --- a/tests/Forms.Latte3/n-name.form.phpt +++ b/tests/Forms.Latte3/n-name.form.phpt @@ -7,10 +7,6 @@ use Tester\Assert; require __DIR__ . '/../bootstrap.php'; -if (version_compare(Latte\Engine::VERSION, '3', '<')) { - Tester\Environment::skip('Test for Latte 3'); -} - $latte = new Latte\Engine; $latte->setLoader(new Latte\Loaders\StringLoader); @@ -19,14 +15,13 @@ $latte->addExtension(new FormsExtension); Assert::match( <<<'XX' %A% - $form = $this->global->formsStack[] = $this->global->uiControl['foo'] /* line 1 */; - Nette\Bridges\FormsLatte\Runtime::initializeForm($form); + $this->global->forms->begin($form = $this->global->uiControl['foo']) /* line 1 */; echo 'global->formsStack), [], false) /* line 1 */; + echo $this->global->forms->renderFormBegin([], false) /* line 1 */; echo '>'; - echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd(end($this->global->formsStack), false) /* line 1 */; + echo $this->global->forms->renderFormEnd(false) /* line 1 */; echo ''; - array_pop($this->global->formsStack); + $this->global->forms->end(); %A% XX, $latte->compile('
'), @@ -36,19 +31,18 @@ Assert::match( Assert::match( <<<'XX' %A% - $form = $this->global->formsStack[] = $this->global->uiControl['foo'] /* line 1 */; - Nette\Bridges\FormsLatte\Runtime::initializeForm($form); + $this->global->forms->begin($form = $this->global->uiControl['foo']) /* line 1 */; $ʟ_tag[0] = ''; if (0) /* line 1 */ { echo '<'; echo $ʟ_tmp = 'form' /* line 1 */; $ʟ_tag[0] = '' . $ʟ_tag[0]; - echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin(end($this->global->formsStack), [], false) /* line 1 */; + echo $this->global->forms->renderFormBegin([], false) /* line 1 */; echo '>'; } - echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd(end($this->global->formsStack), false) /* line 1 */; + echo $this->global->forms->renderFormEnd(false) /* line 1 */; echo $ʟ_tag[0]; - array_pop($this->global->formsStack); + $this->global->forms->end(); %A% XX, $latte->compile('
'), diff --git a/tests/Forms.Latte3/n-name.input.phpt b/tests/Forms.Latte3/n-name.input.phpt index 0572ddb36..164845451 100644 --- a/tests/Forms.Latte3/n-name.input.phpt +++ b/tests/Forms.Latte3/n-name.input.phpt @@ -7,22 +7,18 @@ use Tester\Assert; require __DIR__ . '/../bootstrap.php'; -if (version_compare(Latte\Engine::VERSION, '3', '<')) { - Tester\Environment::skip('Test for Latte 3'); -} - $latte = new Latte\Engine; $latte->setLoader(new Latte\Loaders\StringLoader); $latte->addExtension(new FormsExtension); Assert::match( - '%A%echo ($ʟ_elem = Nette\Bridges\FormsLatte\Runtime::item(\'foo\', $this->global)->getControlPart())->attributes() %A%', + '%A%echo ($ʟ_elem = $this->global->forms->item(\'foo\')->getControlPart())->attributes() %A%', $latte->compile(''), ); Assert::match( - '%A%echo ($ʟ_elem = Nette\Bridges\FormsLatte\Runtime::item(\'foo\', $this->global)->getControlPart(\'\'))->attributes() %A%', + '%A%echo ($ʟ_elem = $this->global->forms->item(\'foo\')->getControlPart(\'\'))->attributes() %A%', $latte->compile(''), ); @@ -33,11 +29,11 @@ Assert::exception( ); Assert::match( - '%A%echo ($ʟ_elem = Nette\Bridges\FormsLatte\Runtime::item(\'foo\', $this->global)->getControlPart(\'x\'))->attributes() %A%', + '%A%echo ($ʟ_elem = $this->global->forms->item(\'foo\')->getControlPart(\'x\'))->attributes() %A%', $latte->compile(''), ); Assert::match( - '%A%echo ($ʟ_elem = Nette\Bridges\FormsLatte\Runtime::item(\'foo\', $this->global)->getControlPart(\'x\'))->attributes() %A%', + '%A%echo ($ʟ_elem = $this->global->forms->item(\'foo\')->getControlPart(\'x\'))->attributes() %A%', $latte->compile(''), ); diff --git a/tests/Forms.Latte3/templates/forms.latte b/tests/Forms.Latte3/templates/forms.latte index 7196558bc..91153dcfd 100644 --- a/tests/Forms.Latte3/templates/forms.latte +++ b/tests/Forms.Latte3/templates/forms.latte @@ -80,9 +80,3 @@ -{/formContext myForm} diff --git a/tests/Forms.Latte3/{input}.phpt b/tests/Forms.Latte3/{input}.phpt index 798c091ce..02b236220 100644 --- a/tests/Forms.Latte3/{input}.phpt +++ b/tests/Forms.Latte3/{input}.phpt @@ -7,32 +7,28 @@ use Tester\Assert; require __DIR__ . '/../bootstrap.php'; -if (version_compare(Latte\Engine::VERSION, '3', '<')) { - Tester\Environment::skip('Test for Latte 3'); -} - $latte = new Latte\Engine; $latte->setLoader(new Latte\Loaders\StringLoader); $latte->addExtension(new FormsExtension); Assert::match( - '%A%echo Nette\Bridges\FormsLatte\Runtime::item(\'foo\', $this->global)->getControl() %A%', + '%A%echo $this->global->forms->item(\'foo\')->getControl() %A%', $latte->compile('{input foo}'), ); Assert::match( - '%A%echo Nette\Bridges\FormsLatte\Runtime::item(\'foo\', $this->global)->getControl()->addAttributes([\'class\' => \'foo\']) %A%', + '%A%echo $this->global->forms->item(\'foo\')->getControl()->addAttributes([\'class\' => \'foo\']) %A%', $latte->compile('{input foo class => foo}'), ); Assert::match( - '%A%echo Nette\Bridges\FormsLatte\Runtime::item(\'foo\', $this->global)->getControl()->addAttributes([\'class\' => \'foo\']) %A%', + '%A%echo $this->global->forms->item(\'foo\')->getControl()->addAttributes([\'class\' => \'foo\']) %A%', $latte->compile('{input foo, class => foo}'), ); Assert::match( - '%A%echo Nette\Bridges\FormsLatte\Runtime::item(\'foo\', $this->global)->getControlPart(\'\') %A%', + '%A%echo $this->global->forms->item(\'foo\')->getControlPart(\'\') %A%', $latte->compile('{input foo:}'), ); @@ -43,31 +39,31 @@ Assert::exception( ); Assert::match( - '%A%echo Nette\Bridges\FormsLatte\Runtime::item(\'foo\', $this->global)->getControlPart(\'\') %A%', + '%A%echo $this->global->forms->item(\'foo\')->getControlPart(\'\') %A%', $latte->compile('{input foo:,}'), ); Assert::match( - '%A%echo Nette\Bridges\FormsLatte\Runtime::item(\'foo\', $this->global)->getControlPart(\'\')->addAttributes([\'class\' => \'foo\']) %A%', + '%A%echo $this->global->forms->item(\'foo\')->getControlPart(\'\')->addAttributes([\'class\' => \'foo\']) %A%', $latte->compile('{input foo:, class => foo}'), ); Assert::match( - '%A%echo Nette\Bridges\FormsLatte\Runtime::item(\'foo\', $this->global)->getControlPart(\'x\') %A%', + '%A%echo $this->global->forms->item(\'foo\')->getControlPart(\'x\') %A%', $latte->compile('{input foo:x}'), ); Assert::match( - '%A%echo Nette\Bridges\FormsLatte\Runtime::item(\'foo\', $this->global)->getControlPart(\'x\')->addAttributes([\'class\' => \'foo\']) %A%', + '%A%echo $this->global->forms->item(\'foo\')->getControlPart(\'x\')->addAttributes([\'class\' => \'foo\']) %A%', $latte->compile('{input foo:x, class => foo}'), ); Assert::match( - '%A%echo Nette\Bridges\FormsLatte\Runtime::item(\'foo\', $this->global)->getControlPart(\'x\') %A%', + '%A%echo $this->global->forms->item(\'foo\')->getControlPart(\'x\') %A%', $latte->compile('{input "foo":"x"}'), ); Assert::match( - '%A%echo Nette\Bridges\FormsLatte\Runtime::item(\'foo\', $this->global)->getControlPart(\'x\') %A%', + '%A%echo $this->global->forms->item(\'foo\')->getControlPart(\'x\') %A%', $latte->compile('{input "foo" : "x"}'), ); diff --git a/tests/Forms.Latte3/{label}.phpt b/tests/Forms.Latte3/{label}.phpt index a581a3eb3..b09ceca04 100644 --- a/tests/Forms.Latte3/{label}.phpt +++ b/tests/Forms.Latte3/{label}.phpt @@ -7,32 +7,28 @@ use Tester\Assert; require __DIR__ . '/../bootstrap.php'; -if (version_compare(Latte\Engine::VERSION, '3', '<')) { - Tester\Environment::skip('Test for Latte 3'); -} - $latte = new Latte\Engine; $latte->setLoader(new Latte\Loaders\StringLoader); $latte->addExtension(new FormsExtension); Assert::match( - '%A%echo ($ʟ_label = Nette\Bridges\FormsLatte\Runtime::item(\'foo\', $this->global)->getLabel()) %A%', + '%A%echo ($ʟ_label = $this->global->forms->item(\'foo\')->getLabel()) %A%', $latte->compile('{label foo /}'), ); Assert::match( - '%A%echo ($ʟ_label = Nette\Bridges\FormsLatte\Runtime::item(\'foo\', $this->global)->getLabel())?->addAttributes([\'class\' => \'foo\']) %A%', + '%A%echo ($ʟ_label = $this->global->forms->item(\'foo\')->getLabel())?->addAttributes([\'class\' => \'foo\']) %A%', $latte->compile('{label foo class => foo /}'), ); Assert::match( - '%A%echo ($ʟ_label = Nette\Bridges\FormsLatte\Runtime::item(\'foo\', $this->global)->getLabel())?->addAttributes([\'class\' => \'foo\']) %A%', + '%A%echo ($ʟ_label = $this->global->forms->item(\'foo\')->getLabel())?->addAttributes([\'class\' => \'foo\']) %A%', $latte->compile('{label foo, class => foo /}'), ); Assert::match( - '%A%echo ($ʟ_label = Nette\Bridges\FormsLatte\Runtime::item(\'foo\', $this->global)->getLabelPart(\'\')) %A%', + '%A%echo ($ʟ_label = $this->global->forms->item(\'foo\')->getLabelPart(\'\')) %A%', $latte->compile('{label foo: /}'), ); @@ -43,31 +39,31 @@ Assert::exception( ); Assert::match( - '%A%echo ($ʟ_label = Nette\Bridges\FormsLatte\Runtime::item(\'foo\', $this->global)->getLabelPart(\'\')) %A%', + '%A%echo ($ʟ_label = $this->global->forms->item(\'foo\')->getLabelPart(\'\')) %A%', $latte->compile('{label foo:, /}'), ); Assert::match( - '%A%echo ($ʟ_label = Nette\Bridges\FormsLatte\Runtime::item(\'foo\', $this->global)->getLabelPart(\'\'))?->addAttributes([\'class\' => \'foo\']) %A%', + '%A%echo ($ʟ_label = $this->global->forms->item(\'foo\')->getLabelPart(\'\'))?->addAttributes([\'class\' => \'foo\']) %A%', $latte->compile('{label foo:, class => foo /}'), ); Assert::match( - '%A%echo ($ʟ_label = Nette\Bridges\FormsLatte\Runtime::item(\'foo\', $this->global)->getLabelPart(\'x\')) %A%', + '%A%echo ($ʟ_label = $this->global->forms->item(\'foo\')->getLabelPart(\'x\')) %A%', $latte->compile('{label foo:x /}'), ); Assert::match( - '%A%echo ($ʟ_label = Nette\Bridges\FormsLatte\Runtime::item(\'foo\', $this->global)->getLabelPart(\'x\'))?->addAttributes([\'class\' => \'foo\']) %A%', + '%A%echo ($ʟ_label = $this->global->forms->item(\'foo\')->getLabelPart(\'x\'))?->addAttributes([\'class\' => \'foo\']) %A%', $latte->compile('{label foo:x, class => foo /}'), ); Assert::match( - '%A%echo ($ʟ_label = Nette\Bridges\FormsLatte\Runtime::item(\'foo\', $this->global)->getLabelPart(\'x\')) %A%', + '%A%echo ($ʟ_label = $this->global->forms->item(\'foo\')->getLabelPart(\'x\')) %A%', $latte->compile('{label "foo":"x" /}'), ); Assert::match( - '%A%echo ($ʟ_label = Nette\Bridges\FormsLatte\Runtime::item(\'foo\', $this->global)->getLabelPart(\'x\')) %A%', + '%A%echo ($ʟ_label = $this->global->forms->item(\'foo\')->getLabelPart(\'x\')) %A%', $latte->compile('{label "foo" : "x" /}'), ); diff --git a/tests/Forms/Container.getControls().phpt b/tests/Forms/Container.getControls().phpt index 5c4d2bef0..3c605a6ef 100644 --- a/tests/Forms/Container.getControls().phpt +++ b/tests/Forms/Container.getControls().phpt @@ -15,22 +15,4 @@ $form->addContainer('cont') ->addText('name'); $controls = $form->getControls(); - -$names = $values = []; -foreach ($controls as $name => $value) { - $names[] = $name; - $values[] = $value; -} - -Assert::same(['name', 'age', 'name'], $names); -Assert::same([$form['name'], $form['age'], $form['cont-name']], $values); - -// again -$names = $values = []; -foreach ($controls as $name => $value) { - $names[] = $name; - $values[] = $value; -} - -Assert::same(['name', 'age', 'name'], $names); -Assert::same([$form['name'], $form['age'], $form['cont-name']], $values); +Assert::same([$form['name'], $form['age'], $form['cont-name']], $controls); diff --git a/tests/Forms/Container.values.mapping.phpt b/tests/Forms/Container.values.mapping.phpt index a51c618e0..33b142953 100644 --- a/tests/Forms/Container.values.mapping.phpt +++ b/tests/Forms/Container.values.mapping.phpt @@ -10,8 +10,7 @@ use Tester\Assert; require __DIR__ . '/../bootstrap.php'; -#[AllowDynamicProperties] -class FormData +class FormData extends stdClass { public string $title; @@ -19,7 +18,7 @@ class FormData } -class FormFirstLevel +class FormFirstLevel extends stdClass { public string $name; @@ -29,7 +28,7 @@ class FormFirstLevel } -class FormSecondLevel +class FormSecondLevel extends stdClass { public string $city; } diff --git a/tests/Forms/Controls.UploadControl.loadData.phpt b/tests/Forms/Controls.UploadControl.loadData.phpt index 73c877511..b43a5d71f 100644 --- a/tests/Forms/Controls.UploadControl.loadData.phpt +++ b/tests/Forms/Controls.UploadControl.loadData.phpt @@ -146,6 +146,32 @@ test('empty data', function () { }); +test('missing data + nullable', function () { + $form = new Form; + $input = $form->addMultiUpload('empty') + ->setNullable() // has no effect + ->setRequired(); + + Assert::false($form->isValid()); + Assert::equal([], $input->getValue()); + Assert::false($input->isFilled()); + Assert::false($input->isOk()); +}); + + +test('empty data + nullable', function () { + $form = new Form; + $input = $form->addUpload('missing') + ->setNullable() + ->setRequired(); + + Assert::false($form->isValid()); + Assert::null($input->getValue()); + Assert::false($input->isFilled()); + Assert::false($input->isOk()); +}); + + test('malformed data', function () { $form = new Form; $input = $form->addUpload('invalid1'); diff --git a/tests/Forms/expected/Forms.renderer.1.expect b/tests/Forms/expected/Forms.renderer.1.expect index 8b0082a2e..71aeb6b7f 100644 --- a/tests/Forms/expected/Forms.renderer.1.expect +++ b/tests/Forms/expected/Forms.renderer.1.expect @@ -14,7 +14,7 @@ - + Enter your age @@ -54,14 +54,14 @@ - + Enter your shipping address - + Select your country @@ -81,7 +81,7 @@ - + Reenter your password diff --git a/tests/Forms/expected/Forms.renderer.2.expect b/tests/Forms/expected/Forms.renderer.2.expect index 4fbec753b..4b4872f59 100644 --- a/tests/Forms/expected/Forms.renderer.2.expect +++ b/tests/Forms/expected/Forms.renderer.2.expect @@ -13,14 +13,14 @@
-
• +
Age must be numeric value
-
+
Please select a valid option.
@@ -73,7 +73,7 @@
-
(at least 3 characters) +
(at least 3 characters) The password is too short: it must be at least 3 characters
diff --git a/tests/Forms/expected/Forms.renderer.translate.expect b/tests/Forms/expected/Forms.renderer.translate.expect index e1230b986..125b4ac49 100644 --- a/tests/Forms/expected/Forms.renderer.translate.expect +++ b/tests/Forms/expected/Forms.renderer.translate.expect @@ -15,7 +15,7 @@ - + WEAK PASSWORD diff --git a/tests/netteForms/karma.conf.js b/tests/netteForms/karma.conf.cjs similarity index 76% rename from tests/netteForms/karma.conf.js rename to tests/netteForms/karma.conf.cjs index d92d72c03..3712c64dd 100644 --- a/tests/netteForms/karma.conf.js +++ b/tests/netteForms/karma.conf.cjs @@ -1,11 +1,11 @@ -module.exports = function(config) { +module.exports = function (config) { config.set({ basePath: '', frameworks: ['jasmine'], browsers: ['ChromeHeadless'], files: [ '../../src/assets/netteForms.js', - 'spec/*Spec.js' + 'spec/*Spec.js', ], autoWatch: false, singleRun: true, diff --git a/tests/netteForms/package.json b/tests/netteForms/package.json deleted file mode 100644 index 2b519789e..000000000 --- a/tests/netteForms/package.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "devDependencies": { - "eslint": "^8.52.0", - "jasmine": "^5.1.0", - "jasmine-core": "^5.1.1", - "karma": "^6.4.2", - "karma-chrome-launcher": "^3.2.0", - "karma-jasmine": "^5.1.0" - } -} diff --git a/tests/netteForms/spec/Nette.validatorsSpec.js b/tests/netteForms/spec/Nette.validatorsSpec.js index cd9938a05..0db1bd357 100644 --- a/tests/netteForms/spec/Nette.validatorsSpec.js +++ b/tests/netteForms/spec/Nette.validatorsSpec.js @@ -90,7 +90,7 @@ describe('Nette.validators', () => { it('url', () => { - let v = {value: null}; + let v = { value: null }; expect(Nette.validators.url(null, null, '', v)).toBe(false); expect(Nette.validators.url(null, null, 'hello', v)).toBe(true); expect(v.value).toBe('https://hello');