Skip to content

Commit 0d32637

Browse files
committed
Only include data-* attributes on DOM/HTML render, not HTML-only# Please enter the commit message for your changes. Lines starting
1 parent 60210a6 commit 0d32637

File tree

1 file changed

+12
-17
lines changed

1 file changed

+12
-17
lines changed

model-bind.js

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -513,9 +513,10 @@
513513
this._model = null;
514514
this._usedBindings = [];
515515
this.ui = api.create({});
516+
this.includeDataProperties = false;
516517
}
517518
BindingContext.prototype = {
518-
_subContext: function (model, binding, uiPath) {
519+
_subContext: function (model, binding, uiPath, includeDataProperties) {
519520
var result = Object.create(this._root);
520521
result._model = model;
521522
result._usedBindings = [binding];
@@ -527,6 +528,7 @@
527528
if (result.ui.jsonType() !== 'object') {
528529
result.ui.set('', {});
529530
}
531+
result.includeDataProperties = includeDataProperties || this.includeDataProperties;
530532
return result;
531533
},
532534
selectBinding: function (model, tag, attrs) {
@@ -583,9 +585,6 @@
583585
}
584586
data.tag = data.tag || 'span';
585587
data.attrs = data.attrs || {};
586-
data.attrs[dataPropertyStoreKey] = data.key;
587-
data.attrs[dataPropertyPath] = data.path;
588-
data.attrs[dataPropertyUiPath] = data.ui;
589588
data.ui = data.ui || '';
590589
var rootModel = thisContext._dataStore._getRootModel(data.key);
591590
if (!rootModel) {
@@ -594,7 +593,12 @@
594593
return callback(error, openTag(data.tag, data.attrs) + errorHtml + closeTag(data.tag, data.attrs));
595594
}
596595
var model = rootModel.modelForPath(data.path);
597-
data.attrs[dataPropertyState] = rootModel.state;
596+
if (thisContext.includeDataProperties) {
597+
data.attrs[dataPropertyStoreKey] = data.key;
598+
data.attrs[dataPropertyPath] = data.path;
599+
data.attrs[dataPropertyUiPath] = data.ui;
600+
data.attrs[dataPropertyState] = rootModel.state;
601+
}
598602
thisContext._renderHtml(model, data.tag, data.attrs, data.ui, callback);
599603
}, callback);
600604
},
@@ -679,7 +683,7 @@
679683
var oldState = model._root.state;
680684

681685
var binding = thisContext.selectBinding(model, tag, attrs);
682-
var context = thisContext._subContext(model, binding, uiPath);
686+
var context = thisContext._subContext(model, binding, uiPath, true);
683687

684688
if (element.boundJsonModel) {
685689
if (model === element.boundJsonModel) {
@@ -719,22 +723,13 @@
719723
}
720724
}
721725

722-
723-
724-
// TODO: render HTML instead of coercing DOM
725-
726726
context._renderInnerHtml(model, binding, tag, attrs, function (error, innerHtml) {
727727
console.log('Rendered HTML:', innerHtml);
728+
// DEBUG
729+
innerHtml = '<span class="debug">DOM/HTML render</span>' + innerHtml;
728730
element.innerHTML = innerHtml;
729731
htmlReady(error);
730732
});
731-
732-
/*
733-
thisContext._updateDom(element, tag, attrs, function (error) {
734-
binding.bindDom(context, model, element);
735-
return callback(error);
736-
});
737-
*/
738733
});
739734
},
740735
_coerceDom: function coerceDom(subject, target, cullSize, callback) {

0 commit comments

Comments
 (0)