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

Remove experiment for input-debounced. Update docs. #9724

Merged
merged 1 commit into from
Jun 5, 2017
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
2 changes: 1 addition & 1 deletion spec/amp-actions-and-events.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ Including: `input[type=radio]`, `input[type=checkbox]`, `input[type=range]`, and
</tr>
<tr>
<td>input-debounced</td>
<td>Fired when the value of the element is changed. This is similar to the standard input event, but it only fires when 300ms have passed after the value of the input has stopped changing. This is currently experimental, so [the "input-debounced" experiment must be enabled](https://www.ampproject.org/docs/reference/experimental) before using.</td>
<td>Fired when the value of the element is changed. This is similar to the standard input event, but it only fires when 300ms have passed after the value of the input has stopped changing.</td>
<td>Various, see below.</td>
</tr>
</table>
Expand Down
6 changes: 0 additions & 6 deletions src/service/action-impl.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import {
} from '../service';
import {getMode} from '../mode';
import {isArray} from '../types';
import {isExperimentOn} from '../experiments';
import {map} from '../utils/object';
import {timerFor} from '../services';
import {vsyncFor} from '../services';
Expand Down Expand Up @@ -364,11 +363,6 @@ export class ActionService {
for (let i = 0; i < action.actionInfos.length; i++) {
const actionInfo = action.actionInfos[i];

if (actionInfo.event === 'input-debounced') {
user().assert(isExperimentOn(this.ampdoc.win, 'input-debounced'),
'Enable "input-debounced" experiment to use input-debounced');
}

// Replace any variables in args with data in `event`.
const args = applyActionInfoArgs(actionInfo.args, event);

Expand Down
34 changes: 1 addition & 33 deletions test/functional/test-action.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import {
import {AmpDocSingle} from '../../src/service/ampdoc-impl';
import {KeyCodes} from '../../src/utils/key-codes';
import {createCustomEvent} from '../../src/event-helper';
import {toggleExperiment} from '../../src/experiments';
import {setParentWindow} from '../../src/service';
import * as sinon from 'sinon';

Expand Down Expand Up @@ -927,14 +926,13 @@ describes.sandboxed('Action global target', {}, () => {

describes.fakeWin('Core events', {amp: true}, env => {
let sandbox;
let win;
let window;
let document;
let action;
let triggerPromise;

beforeEach(() => {
win = window = env.win;
window = env.win;
document = window.document;
sandbox = env.sandbox;
sandbox.stub(window.document, 'addEventListener');
Expand All @@ -954,10 +952,6 @@ describes.fakeWin('Core events', {amp: true}, env => {
action.vsync_ = {mutate: callback => callback()};
});

afterEach(() => {
toggleExperiment(win, 'input-debounced', false);
});

it('should trigger tap event on click', () => {
expect(window.document.addEventListener).to.have.been.calledWith('click');
const handler = window.document.addEventListener.getCall(0).args[1];
Expand Down Expand Up @@ -1051,7 +1045,6 @@ describes.fakeWin('Core events', {amp: true}, env => {
});

it('should trigger input-debounced event on input', () => {
toggleExperiment(window, 'input-debounced', true);
sandbox.stub(action, 'invoke_');
const handler = window.document.addEventListener.getCall(4).args[1];
const element = document.createElement('input');
Expand All @@ -1070,31 +1063,6 @@ describes.fakeWin('Core events', {amp: true}, env => {
const value = event.target.value;
return value == 'foo bar baz';
}));
toggleExperiment(window, 'input-debounced', false);
}, () => {
assert.fail('Should succeed with experiment.');
});
});

it('should not handle input-debounced event without experiment', () => {
const handler = window.document.addEventListener.getCall(4).args[1];
const element = document.createElement('input');
element.setAttribute('on', 'input-debounced:body.hide');
element.value = 'foo bar baz';
const event = {target: element};
handler(event);

return triggerPromise.then(() => {
assert.fail('Should not succeed without experiment.');
}, error => {
expect(error).to.match(/"input-debounced" experiment/);
expect(action.trigger).to.have.been.calledWith(
element,
'input-debounced',
sinon.match(event => {
const value = event.target.value;
return value == 'foo bar baz';
}));
});
});

Expand Down