Skip to content

Commit

Permalink
Remove experiment for input-debounced. Update docs. (#9724)
Browse files Browse the repository at this point in the history
  • Loading branch information
cvializ committed Jun 5, 2017
1 parent c7202a1 commit 16d86f7
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 40 deletions.
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

0 comments on commit 16d86f7

Please sign in to comment.