Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should raise change event target.value is set on input event (closes #1580) #1581

Merged
merged 1 commit into from
Apr 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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