From 3e9c54baf6b33ba3437d81c42fe6920f79c0a97f Mon Sep 17 00:00:00 2001 From: Ralf Sternberg Date: Mon, 6 Feb 2017 11:43:54 +0100 Subject: [PATCH] Remove prefix "DOM" from modules 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 --- src/tabris/{DOMDocument.js => Document.js} | 4 ++-- src/tabris/{DOMEvent.js => Event.js} | 4 ++-- src/tabris/{DOMProgressEvent.js => ProgressEvent.js} | 2 +- src/tabris/XMLHttpRequest.js | 6 +++--- src/tabris/main.js | 6 +++--- .../tabris/{DOMDocument.test.js => Document.test.js} | 8 ++++---- test/tabris/{DOMEvent.test.js => Event.test.js} | 12 ++++++------ 7 files changed, 21 insertions(+), 21 deletions(-) rename src/tabris/{DOMDocument.js => Document.js} (95%) rename src/tabris/{DOMEvent.js => Event.js} (95%) rename src/tabris/{DOMProgressEvent.js => ProgressEvent.js} (87%) rename test/tabris/{DOMDocument.test.js => Document.test.js} (95%) rename test/tabris/{DOMEvent.test.js => Event.test.js} (93%) diff --git a/src/tabris/DOMDocument.js b/src/tabris/Document.js similarity index 95% rename from src/tabris/DOMDocument.js rename to src/tabris/Document.js index 9c701a742..548b10b12 100644 --- a/src/tabris/DOMDocument.js +++ b/src/tabris/Document.js @@ -1,4 +1,4 @@ -import DOMEvent, {addDOMEventTargetMethods} from './DOMEvent'; +import Event, {addDOMEventTargetMethods} from './Event'; let noop = function() {}; @@ -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); diff --git a/src/tabris/DOMEvent.js b/src/tabris/Event.js similarity index 95% rename from src/tabris/DOMEvent.js rename to src/tabris/Event.js index 0ab36821f..fdc3adf98 100644 --- a/src/tabris/DOMEvent.js +++ b/src/tabris/Event.js @@ -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') { @@ -13,7 +13,7 @@ export default function DOMEvent(type, eventInitDict) { } } -DOMEvent.prototype = { +Event.prototype = { NONE: 0, CAPTURING_PHASE: 1, AT_TARGET: 2, diff --git a/src/tabris/DOMProgressEvent.js b/src/tabris/ProgressEvent.js similarity index 87% rename from src/tabris/DOMProgressEvent.js rename to src/tabris/ProgressEvent.js index 6ecbcf438..1bec36735 100644 --- a/src/tabris/DOMProgressEvent.js +++ b/src/tabris/ProgressEvent.js @@ -1,5 +1,5 @@ import {extendPrototype} from './util'; -import Event from './DOMEvent'; +import Event from './Event'; export default function ProgressEvent(type) { this.type = type; diff --git a/src/tabris/XMLHttpRequest.js b/src/tabris/XMLHttpRequest.js index c2351076f..d6edec4f7 100644 --- a/src/tabris/XMLHttpRequest.js +++ b/src/tabris/XMLHttpRequest.js @@ -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', @@ -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; } diff --git a/src/tabris/main.js b/src/tabris/main.js index 009d26d2e..dfa98fa0a 100644 --- a/src/tabris/main.js +++ b/src/tabris/main.js @@ -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'; diff --git a/test/tabris/DOMDocument.test.js b/test/tabris/Document.test.js similarity index 95% rename from test/tabris/DOMDocument.test.js rename to test/tabris/Document.test.js index 13a683bd5..563caef98 100644 --- a/test/tabris/DOMDocument.test.js +++ b/test/tabris/Document.test.js @@ -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; @@ -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() { diff --git a/test/tabris/DOMEvent.test.js b/test/tabris/Event.test.js similarity index 93% rename from test/tabris/DOMEvent.test.js rename to test/tabris/Event.test.js index 439734e5c..a35d66059 100644 --- a/test/tabris/DOMEvent.test.js +++ b/test/tabris/Event.test.js @@ -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; @@ -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); @@ -33,12 +33,12 @@ 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); }); @@ -46,7 +46,7 @@ describe('DOMEvent', function() { }); 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);