Skip to content

Commit

Permalink
fix `Onclick handler probably doesn't work after click on 'Submit' bu…
Browse files Browse the repository at this point in the history
…tton in form` (close #1291) (#1294)

* fix `Onclick handler probably doesn't work after click on 'Submit' button in form` (close #1291)

* test refactoring
  • Loading branch information
LavrovArtem authored and helen-dikareva committed Sep 6, 2017
1 parent 632f134 commit 6d3dab2
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/client/sandbox/code-instrumentation/properties/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,12 @@ export default class PropertyAccessorsInstrumentation extends SandboxBase {
action: {
condition: el => domUtils.isDomElement(el) && domProcessor.isUrlAttr(el, 'action'),

get: el => PropertyAccessorsInstrumentation._getUrlAttr(el, 'action'),
get: el => {
if (domUtils.isDomElement(el.action))
return el.action;

return PropertyAccessorsInstrumentation._getUrlAttr(el, 'action');
},
set: (el, value) => {
el.setAttribute('action', value);

Expand Down
29 changes: 29 additions & 0 deletions test/client/fixtures/sandbox/code-instrumentation/getters-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -606,3 +606,32 @@ test('document.activeElement when it equals null (GH-1226)', function () {

div.parentNode.removeChild(div);
});

test('form.action should return element when the form contains element with the "action" attribute name (GH-1291)', function () {
var form = document.createElement('form');
var input = document.createElement('input');
var nativeForm = nativeMethods.createElement.call(document, 'form');
var nativeInput = nativeMethods.createElement.call(document, 'input');

form.setAttribute('action', 'http://example.com/test1');
input.setAttribute('name', 'action');
nativeMethods.setAttribute.call(nativeForm, 'action', 'http://example.com/test1');
nativeMethods.setAttribute.call(nativeInput, 'name', 'action');

strictEqual(getProperty(form, 'action'), nativeForm.action);

form.appendChild(input);
nativeForm.appendChild(nativeInput);

strictEqual(getProperty(form, 'action').tagName, nativeForm.action.tagName);

setProperty(form, 'action', 'http://example.com/test2');
nativeForm.action = 'http://example.com/test2';

strictEqual(getProperty(form, 'action').tagName, nativeForm.action.tagName);

form.removeChild(input);
nativeForm.removeChild(nativeInput);

strictEqual(getProperty(form, 'action'), nativeForm.action);
});

0 comments on commit 6d3dab2

Please sign in to comment.