Issue #3269152 by yogeshmpawar, longwave, catch: Remove element_settings BC layer in ajax.js
parent
2c9ac6555a
commit
189d5a84d6
|
@ -417,16 +417,6 @@
|
|||
*/
|
||||
this.element = element;
|
||||
|
||||
/**
|
||||
* @deprecated in drupal:8.5.0 and is removed from drupal:10.0.0.
|
||||
* Use elementSettings.
|
||||
*
|
||||
* @see https://www.drupal.org/node/2928117
|
||||
*
|
||||
* @type {Drupal.Ajax~elementSettings}
|
||||
*/
|
||||
this.element_settings = elementSettings;
|
||||
|
||||
/**
|
||||
* @type {Drupal.Ajax~elementSettings}
|
||||
*/
|
||||
|
|
|
@ -175,7 +175,6 @@
|
|||
}
|
||||
|
||||
this.element = element;
|
||||
this.element_settings = elementSettings;
|
||||
this.elementSettings = elementSettings;
|
||||
|
||||
if (this.element && this.element.form) {
|
||||
|
|
|
@ -187,7 +187,6 @@ canonicalizing
|
|||
canvastext
|
||||
castable
|
||||
catalana
|
||||
catbro
|
||||
catchable
|
||||
ccyy
|
||||
ccyymm
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
/**
|
||||
* @file
|
||||
* Testing behavior for JSWebAssertTest.
|
||||
*/
|
||||
(function ($, Drupal) {
|
||||
/**
|
||||
* Test Ajax command.
|
||||
*
|
||||
* @param {Drupal.Ajax} [ajax]
|
||||
* {@link Drupal.Ajax} object created by {@link Drupal.Ajax}.
|
||||
* @param {object} response
|
||||
* The response from the Ajax request.
|
||||
* @param {string} response.selector
|
||||
* A jQuery selector string.
|
||||
*/
|
||||
Drupal.AjaxCommands.prototype.jsAjaxTestCommand = function (ajax, response) {
|
||||
const $domElement = $(response.selector);
|
||||
ajax.element_settings.cat = 'catbro';
|
||||
|
||||
const data = {
|
||||
element_settings: ajax.element_settings.cat || {},
|
||||
elementSettings: ajax.elementSettings.cat || {},
|
||||
};
|
||||
|
||||
$domElement.html(
|
||||
`<div id="js_ajax_test_form_element">${JSON.stringify(data)}</div>`,
|
||||
);
|
||||
};
|
||||
})(jQuery, Drupal);
|
|
@ -1,18 +0,0 @@
|
|||
/**
|
||||
* DO NOT EDIT THIS FILE.
|
||||
* See the following change record for more information,
|
||||
* https://www.drupal.org/node/2815083
|
||||
* @preserve
|
||||
**/
|
||||
|
||||
(function ($, Drupal) {
|
||||
Drupal.AjaxCommands.prototype.jsAjaxTestCommand = function (ajax, response) {
|
||||
const $domElement = $(response.selector);
|
||||
ajax.element_settings.cat = 'catbro';
|
||||
const data = {
|
||||
element_settings: ajax.element_settings.cat || {},
|
||||
elementSettings: ajax.elementSettings.cat || {}
|
||||
};
|
||||
$domElement.html(`<div id="js_ajax_test_form_element">${JSON.stringify(data)}</div>`);
|
||||
};
|
||||
})(jQuery, Drupal);
|
|
@ -1,5 +0,0 @@
|
|||
name: 'JS Ajax test'
|
||||
description: 'Provides custom ajax commands used for tests'
|
||||
type: module
|
||||
package: Testing
|
||||
version: VERSION
|
|
@ -1,8 +0,0 @@
|
|||
ajax:
|
||||
version: VERSION
|
||||
js:
|
||||
js/js_ajax_test.ajax.js: {}
|
||||
dependencies:
|
||||
- core/jquery
|
||||
- core/drupal
|
||||
- core/drupal.ajax
|
|
@ -1,6 +0,0 @@
|
|||
js_ajax_test.js_ajax_test:
|
||||
path: '/js_ajax_test'
|
||||
defaults:
|
||||
_form: '\Drupal\js_ajax_test\Form\JsAjaxTestForm'
|
||||
requirements:
|
||||
_access: 'TRUE'
|
|
@ -1,22 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\js_ajax_test\Ajax;
|
||||
|
||||
use Drupal\Core\Ajax\CommandInterface;
|
||||
|
||||
/**
|
||||
* Test Ajax command.
|
||||
*/
|
||||
class JsAjaxTestCommand implements CommandInterface {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function render() {
|
||||
return [
|
||||
'command' => 'jsAjaxTestCommand',
|
||||
'selector' => '#js_ajax_test_form_wrapper',
|
||||
];
|
||||
}
|
||||
|
||||
}
|
|
@ -1,64 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\js_ajax_test\Form;
|
||||
|
||||
use Drupal\Core\Ajax\AjaxResponse;
|
||||
use Drupal\Core\Form\FormBase;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\js_ajax_test\Ajax\JsAjaxTestCommand;
|
||||
|
||||
/**
|
||||
* Test form for js_ajax_test.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class JsAjaxTestForm extends FormBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFormId() {
|
||||
return 'js_ajax_test_form';
|
||||
}
|
||||
|
||||
/**
|
||||
* Form for testing the addition of various types of elements via Ajax.
|
||||
*/
|
||||
public function buildForm(array $form, FormStateInterface $form_state) {
|
||||
$form['#attached']['library'][] = 'js_ajax_test/ajax';
|
||||
$form['custom']['#prefix'] = '<div id="js_ajax_test_form_wrapper">';
|
||||
$form['custom']['#suffix'] = '</div>';
|
||||
|
||||
// Button to test for the waitForButton() assertion.
|
||||
$form['test_button'] = [
|
||||
'#type' => 'submit',
|
||||
'#value' => $this->t('Add button'),
|
||||
'#button_type' => 'primary',
|
||||
'#ajax' => [
|
||||
'callback' => [static::class, 'addButton'],
|
||||
'progress' => [
|
||||
'type' => 'throbber',
|
||||
'message' => NULL,
|
||||
],
|
||||
'wrapper' => 'js_ajax_test_form_wrapper',
|
||||
],
|
||||
];
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax callback for the "Add button" button.
|
||||
*/
|
||||
public static function addButton(array $form, FormStateInterface $form_state) {
|
||||
return (new AjaxResponse())
|
||||
->addCommand(new JsAjaxTestCommand());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function submitForm(array &$form, FormStateInterface $form_state) {
|
||||
// An empty implementation, as we never submit the actual form.
|
||||
}
|
||||
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\FunctionalJavascriptTests\Ajax;
|
||||
|
||||
use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
|
||||
|
||||
/**
|
||||
* Tests the compatibility of the ajax.es6.js file.
|
||||
*
|
||||
* @group Ajax
|
||||
*/
|
||||
class BackwardCompatibilityTest extends WebDriverTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $modules = [
|
||||
'js_ajax_test',
|
||||
];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected $defaultTheme = 'stark';
|
||||
|
||||
/**
|
||||
* Ensures Drupal.Ajax.element_settings BC layer.
|
||||
*/
|
||||
public function testAjaxBackwardCompatibility() {
|
||||
$this->drupalGet('/js_ajax_test');
|
||||
$this->click('#edit-test-button');
|
||||
|
||||
$this->assertSession()
|
||||
->waitForElement('css', '#js_ajax_test_form_element');
|
||||
$elements = $this->cssSelect('#js_ajax_test_form_element');
|
||||
$this->assertCount(1, $elements);
|
||||
$json = $elements[0]->getText();
|
||||
$data = json_decode($json, TRUE);
|
||||
$this->assertEquals([
|
||||
'element_settings' => 'catbro',
|
||||
'elementSettings' => 'catbro',
|
||||
], $data);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue