From fa4042d17dc5b8d5146e034c451ebf5120c81a85 Mon Sep 17 00:00:00 2001 From: Sergey Chikuyonok Date: Mon, 19 Nov 2012 18:33:00 +0400 Subject: [PATCH] Externalized XHTML detection, fixed tests --- javascript/actionUtils.js | 11 ++++++++++- javascript/unittest/tests/actions.js | 2 +- javascript/unittest/tests/expandAbbreviation.js | 7 ++++++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/javascript/actionUtils.js b/javascript/actionUtils.js index 261c1035..4fedb1da 100644 --- a/javascript/actionUtils.js +++ b/javascript/actionUtils.js @@ -278,13 +278,22 @@ emmet.define('actionUtils', function(require, _) { var profile = require('resources').getVariable('profile'); if (!profile) { // no forced profile, guess from content // html or xhtml? - profile = editor.getContent().search(/]+XHTML/i) != -1 ? 'xhtml': 'html'; + profile = this.isXHTML(editor) ? 'xhtml': 'html'; } return profile; } return 'xhtml'; + }, + + /** + * Tries to detect if current document is XHTML one. + * @param {IEmmetEditor} editor + * @returns {Boolean} + */ + isXHTML: function(editor) { + return editor.getContent().search(/]+XHTML/i) != -1; } }; }); \ No newline at end of file diff --git a/javascript/unittest/tests/actions.js b/javascript/unittest/tests/actions.js index a74377aa..90b16b62 100644 --- a/javascript/unittest/tests/actions.js +++ b/javascript/unittest/tests/actions.js @@ -408,7 +408,7 @@ test('Wrap With Abbreviation', function() { var wrap = function(abbr, content) { content = emmet.require('utils').escapeText(content); - return emmet.require('wrapWithAbbreviation').wrap(abbr, content); + return emmet.require('wrapWithAbbreviation').wrap(abbr, content, 'html', 'plain'); }; editorStub.replaceContent(''); diff --git a/javascript/unittest/tests/expandAbbreviation.js b/javascript/unittest/tests/expandAbbreviation.js index 54491ac1..596e9170 100644 --- a/javascript/unittest/tests/expandAbbreviation.js +++ b/javascript/unittest/tests/expandAbbreviation.js @@ -32,7 +32,12 @@ function runTest() { var args = _.toArray(arguments); - var result = emmet.expandAbbreviation.apply(emmet, _.initial(args)); + var params = _.initial(args); + if (!params[2]) { + params[2] = 'plain'; + } + + var result = emmet.expandAbbreviation.apply(emmet, params); result = emmet.require('tabStops').processText(result, { escape: function(ch) { return ch;