From 8511f8ab3ed3842545ef49fc151531a919b3ffc1 Mon Sep 17 00:00:00 2001 From: Trevor Parscal Date: Tue, 28 May 2013 12:49:35 +0100 Subject: [PATCH] Treat acronyms like words in camel case names No matter what the W3C says, getDomFromHtmlString is more legible than getDOMFromHTMLString. Change-Id: Ic843b6671871024cce8acd82b6be435599ed168b --- modules/ve/dm/ve.dm.Converter.js | 4 ++-- modules/ve/init/mw/ve.init.mw.Target.js | 11 +++++++---- modules/ve/init/sa/ve.init.sa.Target.js | 2 +- modules/ve/test/dm/ve.dm.Converter.test.js | 6 ++++-- modules/ve/test/dm/ve.dm.example.js | 2 +- modules/ve/test/ui/actions/ve.ui.FormatAction.test.js | 2 +- .../test/ui/actions/ve.ui.IndentationAction.test.js | 2 +- modules/ve/test/ui/actions/ve.ui.ListAction.test.js | 4 ++-- modules/ve/test/ve.test.js | 4 ++-- modules/ve/ve.js | 4 ++-- 10 files changed, 23 insertions(+), 18 deletions(-) diff --git a/modules/ve/dm/ve.dm.Converter.js b/modules/ve/dm/ve.dm.Converter.js index 6f51ae6daf..3b5e53fe46 100644 --- a/modules/ve/dm/ve.dm.Converter.js +++ b/modules/ve/dm/ve.dm.Converter.js @@ -332,7 +332,7 @@ ve.dm.Converter.prototype.createDataElements = function ( modelClass, domElement * @returns {HTMLElement} HTML DOM node */ ve.dm.Converter.prototype.getDomElementFromDataAnnotation = function ( dataAnnotation, doc ) { - var htmlData = dataAnnotation.toHTML(), + var htmlData = dataAnnotation.toHtml(), domElement = doc.createElement( htmlData.tag ); ve.setDomAttributes( domElement, htmlData.attributes ); @@ -897,7 +897,7 @@ ve.dm.Converter.prototype.getDataFromDomRecursion = function ( domElement, wrapp * @returns {HTMLDocument} Document containing the resulting HTML */ ve.dm.Converter.prototype.getDomFromData = function ( documentData, store, internalList ) { - var doc = ve.createDocumentFromHTML( '' ); + var doc = ve.createDocumentFromHtml( '' ); // Set up the converter state this.documentData = documentData; diff --git a/modules/ve/init/mw/ve.init.mw.Target.js b/modules/ve/init/mw/ve.init.mw.Target.js index c0931f17e7..09ee51808f 100644 --- a/modules/ve/init/mw/ve.init.mw.Target.js +++ b/modules/ve/init/mw/ve.init.mw.Target.js @@ -157,7 +157,7 @@ ve.init.mw.Target.onLoad = function ( response ) { ); } else { this.originalHtml = data.content; - this.doc = ve.createDocumentFromHTML( this.originalHtml ); + this.doc = ve.createDocumentFromHtml( this.originalHtml ); /* Don't show notices with no visible html (bug 43013). */ @@ -701,14 +701,17 @@ ve.init.mw.Target.prototype.reportProblem = function ( message ) { 'diff': this.diffHtml, 'originalHtml': this.originalHtml, 'originalData': - // originalHTML only has the body's HTML for now, see TODO comment in ve.init.mw.ViewPageTarget.prototype.setupSurface + // originalHtml only has the body's HTML for now, see TODO comment in + // ve.init.mw.ViewPageTarget.prototype.setupSurface // FIXME: need to expand this data before sending it, see bug 47319 ve.dm.converter.getDataFromDom( - ve.createDocumentFromHTML( '' + this.originalHtml + '' ), + ve.createDocumentFromHtml( '' + this.originalHtml + '' ), store, internalList ).getData(), 'editedData': editedData, - 'editedHtml': this.getHtml( ve.dm.converter.getDomFromData( editedData, store, internalList ) ), + 'editedHtml': this.getHtml( + ve.dm.converter.getDomFromData( editedData, store, internalList ) + ), 'store': doc.data.getUsedStoreValues(), 'wiki': mw.config.get( 'wgDBname' ) }; diff --git a/modules/ve/init/sa/ve.init.sa.Target.js b/modules/ve/init/sa/ve.init.sa.Target.js index e4ecc2af98..d0870cd4e7 100644 --- a/modules/ve/init/sa/ve.init.sa.Target.js +++ b/modules/ve/init/sa/ve.init.sa.Target.js @@ -10,7 +10,7 @@ * * @example * new ve.init.sa.Target( - * $( '
' ).appendTo( 'body' ), ve.createDocumentFromHTML( '

Hello world.

' ) + * $( '
' ).appendTo( 'body' ), ve.createDocumentFromHtml( '

Hello world.

' ) * ); * * @class diff --git a/modules/ve/test/dm/ve.dm.Converter.test.js b/modules/ve/test/dm/ve.dm.Converter.test.js index 7c8da34421..14aff79aeb 100644 --- a/modules/ve/test/dm/ve.dm.Converter.test.js +++ b/modules/ve/test/dm/ve.dm.Converter.test.js @@ -64,7 +64,9 @@ QUnit.test( 'getDataFromDom', function ( assert ) { internalList = new ve.dm.InternalList(); ve.dm.example.preprocessAnnotations( cases[msg].data, store ); assert.deepEqualWithDomElements( - ve.dm.converter.getDataFromDom( ve.createDocumentFromHTML( cases[msg].html ), store, internalList ).getData(), + ve.dm.converter.getDataFromDom( + ve.createDocumentFromHtml( cases[msg].html ), store, internalList + ).getData(), cases[msg].data, msg ); @@ -107,7 +109,7 @@ QUnit.test( 'getDomFromData', function ( assert ) { originalData = ve.copyArray( doc.getFullData() ); assert.equalDomElement( ve.dm.converter.getDomFromData( doc.getFullData(), doc.getStore(), doc.getInternalList() ), - ve.createDocumentFromHTML( cases[msg].normalizedHtml || cases[msg].html ), + ve.createDocumentFromHtml( cases[msg].normalizedHtml || cases[msg].html ), msg ); assert.deepEqualWithDomElements( doc.getFullData(), originalData, msg + ' (data hasn\'t changed)' ); diff --git a/modules/ve/test/dm/ve.dm.example.js b/modules/ve/test/dm/ve.dm.example.js index 8c13ccdf02..f3c1b0a891 100644 --- a/modules/ve/test/dm/ve.dm.example.js +++ b/modules/ve/test/dm/ve.dm.example.js @@ -3173,7 +3173,7 @@ ve.dm.example.domToDataCases = { } }; -ve.dm.example.isolationHTML = +ve.dm.example.isolationHtml = '
  • Item 1
  • Item 2
  • Item 3
' + 'Paragraph' + '
  • Item 4
  • Item 5
  • Item 6
' + diff --git a/modules/ve/test/ui/actions/ve.ui.FormatAction.test.js b/modules/ve/test/ui/actions/ve.ui.FormatAction.test.js index b5096fd02f..ef73a6afdb 100644 --- a/modules/ve/test/ui/actions/ve.ui.FormatAction.test.js +++ b/modules/ve/test/ui/actions/ve.ui.FormatAction.test.js @@ -11,7 +11,7 @@ QUnit.module( 've.ui.FormatAction' ); function runFormatConverterTest( assert, range, type, attributes, expectedSelection, expectedData, msg ) { var selection, - dom = ve.createDocumentFromHTML( ve.dm.example.isolationHTML ), + dom = ve.createDocumentFromHtml( ve.dm.example.isolationHtml ), target = new ve.init.sa.Target( $( '#qunit-fixture' ), dom ), surface = target.surface, formatAction = new ve.ui.FormatAction( surface ), diff --git a/modules/ve/test/ui/actions/ve.ui.IndentationAction.test.js b/modules/ve/test/ui/actions/ve.ui.IndentationAction.test.js index e5b2785a8d..89ec5ea876 100644 --- a/modules/ve/test/ui/actions/ve.ui.IndentationAction.test.js +++ b/modules/ve/test/ui/actions/ve.ui.IndentationAction.test.js @@ -11,7 +11,7 @@ QUnit.module( 've.ui.IndentationAction' ); function runIndentationChangeTest( assert, range, method, expectedSelection, expectedData, expectedOriginalData, msg ) { var selection, - dom = ve.createDocumentFromHTML( ve.dm.example.isolationHTML ), + dom = ve.createDocumentFromHtml( ve.dm.example.isolationHtml ), target = new ve.init.sa.Target( $( '#qunit-fixture' ), dom ), surface = target.surface, indentationAction = new ve.ui.IndentationAction( surface ), diff --git a/modules/ve/test/ui/actions/ve.ui.ListAction.test.js b/modules/ve/test/ui/actions/ve.ui.ListAction.test.js index b25fabbf7e..956cbdc9ae 100644 --- a/modules/ve/test/ui/actions/ve.ui.ListAction.test.js +++ b/modules/ve/test/ui/actions/ve.ui.ListAction.test.js @@ -11,7 +11,7 @@ QUnit.module( 've.ui.ListAction' ); function runListConverterTest( assert, html, method, style, range, expectedSelection, expectedData, expectedOriginalData, msg ) { var selection, - dom = ve.createDocumentFromHTML( html || ve.dm.example.html ), + dom = ve.createDocumentFromHtml( html || ve.dm.example.html ), target = new ve.init.sa.Target( $( '#qunit-fixture' ), dom ), surface = target.surface, listAction = new ve.ui.ListAction( surface ), @@ -52,7 +52,7 @@ QUnit.test( '(un)wrap', function ( assert ) { 'msg': 'wrapping two paragraphs in a list' }, { - 'html': ve.dm.example.isolationHTML, + 'html': ve.dm.example.isolationHtml, 'range': new ve.Range( 191, 211 ), 'method': 'unwrap', 'style': 'bullet', diff --git a/modules/ve/test/ve.test.js b/modules/ve/test/ve.test.js index 2bfe3afc4a..4ddd829a6a 100644 --- a/modules/ve/test/ve.test.js +++ b/modules/ve/test/ve.test.js @@ -823,7 +823,7 @@ QUnit.test( 'batchSplice', 8, function ( assert ) { assert.deepEqual( expected, actual, 'replacing 3 elements with 2100 elements (array)' ); } ); -QUnit.test( 'createDocumentFromHTML', function ( assert ) { +QUnit.test( 'createDocumentFromHtml', function ( assert ) { var key, doc, expectedHead, expectedBody, cases = [ { @@ -853,7 +853,7 @@ QUnit.test( 'createDocumentFromHTML', function ( assert ) { ]; QUnit.expect( cases.length*2 ); for ( key in cases ) { - doc = ve.createDocumentFromHTML( cases[key].html ); + doc = ve.createDocumentFromHtml( cases[key].html ); expectedHead = $( '' ).html( cases[key].head ).get( 0 ); expectedBody = $( '' ).html( cases[key].body ).get( 0 ); assert.equalDomElement( $( 'head', doc ).get( 0 ), expectedHead, cases[key].msg + ' (head)' ); diff --git a/modules/ve/ve.js b/modules/ve/ve.js index f491b96992..af6b608428 100644 --- a/modules/ve/ve.js +++ b/modules/ve/ve.js @@ -1068,10 +1068,10 @@ * @param {string} html HTML string * @returns {HTMLDocument} Document constructed from the HTML string */ - ve.createDocumentFromHTML = function ( html ) { + ve.createDocumentFromHtml = function ( html ) { // Here's how this function should look: // - // var newDocument = document.implementation.createHTMLDocument( '' ); + // var newDocument = document.implementation.createHtmlDocument( '' ); // newDocument.open(); // newDocument.write( html ); // newDocument.close();