Skip to content

Commit

Permalink
Release 19.1.8
Browse files Browse the repository at this point in the history
  • Loading branch information
babich-a committed Nov 22, 2019
1 parent b0f4435 commit 6f544ba
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 14 deletions.
12 changes: 10 additions & 2 deletions js/aspnet.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,17 @@
})(function($, setTemplateEngine, templateRendered, Guid, validationEngine, iteratorUtils, extractTemplateMarkup, encodeHtml) {
var templateCompiler = createTemplateCompiler();
var pendingCreateComponentRoutines = [ ];
var enableAlternateTemplateTags = true;

function createTemplateCompiler() {
var OPEN_TAG = "<%",
CLOSE_TAG = "%>",
ENCODE_QUALIFIER = "-",
INTERPOLATE_QUALIFIER = "=";

var EXTENDED_OPEN_TAG = /[<[]%/g,
EXTENDED_CLOSE_TAG = /%[>\]]/g;

function acceptText(bag, text) {
if(text) {
bag.push("_.push(", JSON.stringify(text), ");");
Expand All @@ -59,12 +63,12 @@

return function(text) {
var bag = ["var _ = [];", "with(obj||{}) {"],
chunks = text.split(OPEN_TAG);
chunks = text.split(enableAlternateTemplateTags ? EXTENDED_OPEN_TAG : OPEN_TAG);

acceptText(bag, chunks.shift());

for(var i = 0; i < chunks.length; i++) {
var tmp = chunks[i].split(CLOSE_TAG);
var tmp = chunks[i].split(enableAlternateTemplateTags ? EXTENDED_CLOSE_TAG : CLOSE_TAG);
if(tmp.length !== 2) {
throw "Template syntax error";
}
Expand Down Expand Up @@ -168,6 +172,10 @@
}
},

enableAlternateTemplateTags: function(value) {
enableAlternateTemplateTags = value;
},

createValidationSummaryItems: function(validationGroup, editorNames) {
var summary = getValidationSummary(validationGroup),
groupConfig,
Expand Down
13 changes: 6 additions & 7 deletions js/ui/editor/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,18 @@ var READONLY_STATE_CLASS = "dx-state-readonly",
var Editor = Widget.inherit({
ctor: function() {
this.showValidationMessageTimeout = null;
this.validationRequest = Callbacks();
this.callBase.apply(this, arguments);
const $element = this.$element();
if($element) {
dataUtils.data($element[0], VALIDATION_TARGET, this);
}

},

_init: function() {
this.callBase();
this.validationRequest = Callbacks();
this._initInnerOptionCache("validationTooltipOptions");

var $element = this.$element();

if($element) {
dataUtils.data($element[0], VALIDATION_TARGET, this);
}
},

_getDefaultOptions: function() {
Expand Down
21 changes: 16 additions & 5 deletions testing/tests/DevExpress.aspnet/aspnet.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,15 +259,21 @@
setTemplateEngine("default");
}
}, function() {
var testTemplate = function(name, templateSource, expected) {
var testTemplate = function(name, templateSource, expected, enableAlternateTemplateTags) {
QUnit.test(name, function(assert) {
var $template = $("#simpleTemplate");

$template.text(templateSource);
$("#button").dxButton({
text: "Test button",
template: $template
});

aspnet.enableAlternateTemplateTags(enableAlternateTemplateTags !== false);
try {
$("#button").dxButton({
text: "Test button",
template: $template
});
} finally {
aspnet.enableAlternateTemplateTags(true);
}

assert.equal($(".dx-button-content").text(), expected);
});
Expand Down Expand Up @@ -317,6 +323,11 @@
"<% var a = '<script>alert(1)</script>'; %><%- a %>",
"<script>alert(1)</script>"
);

QUnit.module("Alternate syntax (T831170)", function() {
testTemplate("enabled", "a [%= 'b' %] c", "a b c");
testTemplate("disabled", "[%= 123 %]", "[%= 123 %]", false);
});
});

QUnit.test("Transcluded content (T691770, T693379)", function(assert) {
Expand Down

0 comments on commit 6f544ba

Please sign in to comment.