Skip to content

Commit

Permalink
[WIP]Should raise change event target.value is set on input event (cl…
Browse files Browse the repository at this point in the history
…oses #1580) (#1581)
  • Loading branch information
AlexKamaev authored and LavrovArtem committed Apr 25, 2018
1 parent c3ed48a commit 4bd8430
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 9 deletions.
5 changes: 4 additions & 1 deletion src/client/sandbox/node/window.js
Original file line number Diff line number Diff line change
Expand Up @@ -674,9 +674,12 @@ export default class WindowSandbox extends SandboxBase {
},
setter: function (value) {
if (this.type.toLowerCase() !== 'file') {

nativeMethods.inputValueSetter.call(this, value);

if (!isShadowUIElement(this) && isTextEditableElementAndEditingAllowed(this))
const valueChanged = value !== nativeMethods.inputValueGetter.call(this);

if (valueChanged && !isShadowUIElement(this) && isTextEditableElementAndEditingAllowed(this))
windowSandbox.elementEditingWatcher.restartWatchingElementEditing(this);
}
else
Expand Down
37 changes: 29 additions & 8 deletions test/client/fixtures/sandbox/event/focus-blur-change-test.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
var SHADOW_UI_CLASSNAME = hammerhead.get('./../shadow-ui/class-name');

var Promise = hammerhead.Promise;
var browserUtils = hammerhead.utils.browser;
var styleUtil = hammerhead.utils.style;
var activeWindowTracker = hammerhead.sandbox.event.focusBlur.activeWindowTracker;
var eventSimulator = hammerhead.sandbox.event.eventSimulator;
var focusBlur = hammerhead.sandbox.event.focusBlur;
var nativeMethods = hammerhead.nativeMethods;
var iframeSandbox = hammerhead.sandbox.iframe;
var Promise = hammerhead.Promise;
var browserUtils = hammerhead.utils.browser;
var styleUtil = hammerhead.utils.style;
var activeWindowTracker = hammerhead.sandbox.event.focusBlur.activeWindowTracker;
var eventSimulator = hammerhead.sandbox.event.eventSimulator;
var focusBlur = hammerhead.sandbox.event.focusBlur;
var nativeMethods = hammerhead.nativeMethods;
var elementEditingWatcher = hammerhead.sandbox.event.elementEditingWatcher;
var iframeSandbox = hammerhead.sandbox.iframe;

var input1 = null;
var input2 = null;
Expand Down Expand Up @@ -550,6 +551,26 @@ asyncTest('blurring body with blur handler', function () {
});
});

test('should raise change event', function () {
var input = document.createElement('input');
var changeRaised = false;

input.className = TEST_ELEMENT_CLASS;

input.onchange = function () {
changeRaised = true;
};

document.body.appendChild(input);
input.focus();
nativeMethods.inputValueSetter.call(input, 'A');

input.value = 'A';

elementEditingWatcher.processElementChanging(input);
ok(changeRaised);
});

module('native methods replacing');

asyncTest('focus() called by client script when browser window is on background', function () {
Expand Down

0 comments on commit 4bd8430

Please sign in to comment.