Skip to content

Commit

Permalink
Remove prefix "DOM" from modules
Browse files Browse the repository at this point in the history
Modules should have the same name as the type they export.
The type names should match the official API, such as Document,
ProgressEvent, etc.

Remove the prefix "DOM" from the module filenames and imports.

This change doesn't change any logic, just renaming.

Change-Id: I368fbaee69a0ba36e99d9c8c815a4fc0dea5d1cf
  • Loading branch information
ralfstx committed Feb 6, 2017
1 parent 681ef9d commit 3e9c54b
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 21 deletions.
4 changes: 2 additions & 2 deletions src/tabris/DOMDocument.js → src/tabris/Document.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import DOMEvent, {addDOMEventTargetMethods} from './DOMEvent';
import Event, {addDOMEventTargetMethods} from './Event';

let noop = function() {};

Expand Down Expand Up @@ -30,7 +30,7 @@ export function addDOMDocument(target) {
return this.head.children.filter(node => node.tagName === tagName.toUpperCase());
},
createEvent() {
return new DOMEvent();
return new Event();
}
};
addDOMEventTargetMethods(target.document);
Expand Down
4 changes: 2 additions & 2 deletions src/tabris/DOMEvent.js → src/tabris/Event.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
let noop = function() {};

export default function DOMEvent(type, eventInitDict) {
export default function Event(type, eventInitDict) {
this.type = type;
this.timeStamp = Date.now();
if (typeof eventInitDict !== 'undefined') {
Expand All @@ -13,7 +13,7 @@ export default function DOMEvent(type, eventInitDict) {
}
}

DOMEvent.prototype = {
Event.prototype = {
NONE: 0,
CAPTURING_PHASE: 1,
AT_TARGET: 2,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {extendPrototype} from './util';
import Event from './DOMEvent';
import Event from './Event';

export default function ProgressEvent(type) {
this.type = type;
Expand Down
6 changes: 3 additions & 3 deletions src/tabris/XMLHttpRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
// Steps are referenced to with a number inside parentheses, e.g. (2)

import NativeObject from './NativeObject';
import DOMEvent, {addDOMEventTargetMethods} from './DOMEvent';
import ProgressEvent from './DOMProgressEvent';
import Event, {addDOMEventTargetMethods} from './Event';
import ProgressEvent from './ProgressEvent';

const CONFIG = {
_type: 'tabris.HttpRequest',
Expand Down Expand Up @@ -615,7 +615,7 @@ function dispatchEvent(type, target) {
}

function initEvent(type, target) {
let event = new DOMEvent(type);
let event = new Event(type);
event.currentTarget = event.target = target;
return event;
}
6 changes: 3 additions & 3 deletions src/tabris/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import App, {create as createApp} from './App';
import Ui, {create as createUi} from './widgets/Ui';
import ContentView from './widgets/ContentView';
import ImageData from './ImageData';
import {addDOMDocument} from './DOMDocument';
import {addDOMEventTargetMethods} from './DOMEvent';
import {addDOMDocument} from './Document';
import {addDOMEventTargetMethods} from './Event';
import {addWindowTimerMethods} from './WindowTimers';
import ProgressEvent from './DOMProgressEvent';
import ProgressEvent from './ProgressEvent';
import Storage, {create as createStorage} from './Storage';
import WebSocket from './WebSocket';
import XMLHttpRequest from './XMLHttpRequest';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {expect, spy, stub, restore} from '../test';
import {addDOMDocument} from '../../src/tabris/DOMDocument';
import DOMEvent from '../../src/tabris/DOMEvent';
import {addDOMDocument} from '../../src/tabris/Document';
import Event from '../../src/tabris/Event';
import NativeBridge from '../../src/tabris/NativeBridge';
import ClientStub from './ClientStub';

describe('DOMDocument', function() {
describe('Document', function() {

let target, client, loadCallback;

Expand Down Expand Up @@ -60,7 +60,7 @@ describe('DOMDocument', function() {

it('can create HTML Element events', function() {
let event = target.document.createEvent();
expect(event).to.be.an.instanceof(DOMEvent);
expect(event).to.be.an.instanceof(Event);
});

describe('script element', function() {
Expand Down
12 changes: 6 additions & 6 deletions test/tabris/DOMEvent.test.js → test/tabris/Event.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {expect, spy} from '../test';
import DOMEvent, {addDOMEventTargetMethods} from '../../src/tabris/DOMEvent';
import Event, {addDOMEventTargetMethods} from '../../src/tabris/Event';

describe('DOMEvent', function() {
describe('Event', function() {

let target;
let listener;
Expand All @@ -15,7 +15,7 @@ describe('DOMEvent', function() {
describe('Event constructor', function() {

it('sets default values', function() {
let event = new DOMEvent('type');
let event = new Event('type');
expect(event.NONE).to.equal(0);
expect(event.CAPTURING_PHASE).to.equal(1);
expect(event.AT_TARGET).to.equal(2);
Expand All @@ -33,20 +33,20 @@ describe('DOMEvent', function() {
});

it('sets type from parameter', function() {
let event = new DOMEvent('type');
let event = new Event('type');
expect(event.type).to.equal('type');
});

it('sets values from eventInitDict parameter', function() {
let event = new DOMEvent('type', {bubbles: true, cancelable: true});
let event = new Event('type', {bubbles: true, cancelable: true});
expect(event.bubbles).to.equal(true);
expect(event.cancelable).to.equal(true);
});

});

describe('Event.prototype.initEvent', function() {
let event = new DOMEvent();
let event = new Event();

it('sets the type, bubbles, cancelable', function() {
event.initEvent('foo', true, true);
Expand Down

0 comments on commit 3e9c54b

Please sign in to comment.