From 38c3acaac6816e7bf35fcdd2942bf1ba1441d925 Mon Sep 17 00:00:00 2001 From: Rafael Weinstein Date: Thu, 11 Jul 2013 21:34:27 -0700 Subject: [PATCH 1/6] More CR cleanup R=arv BUG= Review URL: https://codereview.appspot.com/11204043 --- benchmark/index.html | 40 +++++++++++++++++++-------------------- src/template_element.js | 17 +++++++---------- third_party/ChangeSummary | 2 +- 3 files changed, 28 insertions(+), 31 deletions(-) diff --git a/benchmark/index.html b/benchmark/index.html index d5080b5..50145f6 100644 --- a/benchmark/index.html +++ b/benchmark/index.html @@ -115,10 +115,10 @@

Binding Density

function changeBenchmark() { benchmark = window[benchmarkSelect.value]; - configSelect.innerHTML = ''; + configSelect.textContent = ''; benchmark.configs.forEach(function(config) { var option = document.createElement('option'); - option.innerHTML = config; + option.textContent = config; configSelect.appendChild(option); }); } @@ -133,8 +133,8 @@

Binding Density

goButton.addEventListener('click', function() { goButton.disabled = true; - goButton.innerHTML = 'Running...'; - ul.innerHTML = ''; + goButton.textContent = 'Running...'; + ul.textContent = ''; var bindingDensities = bindingDensityInput.value.split(',').map(function(val) { return Number(val) / 100; @@ -148,8 +148,8 @@

Binding Density

testTypes.forEach(function(testType, i) { var li = document.createElement('li'); - li.innerHTML = testType; - li.setAttribute('style', 'color: ' + colors[i]); + li.textContent = testType; + li.style.color = colors[i]; ul.appendChild(li); }); @@ -159,12 +159,12 @@

Binding Density

datasets = []; - timesCanvas.setAttribute('height', '400'); - timesCanvas.setAttribute('width', '800'); + timesCanvas.height = 400; + timesCanvas.width = 800; timesCanvas.setAttribute('style', ''); var labels = bindingDensities.map(function(density) { - return (density * 100) + '%'; + return density * 100 + '%'; }); var timesArray = []; @@ -176,32 +176,32 @@

Binding Density

var ctx = timesCanvas.getContext("2d"); new Chart(ctx).Line({ - labels : labels, - datasets : timesArray.map(function(times, i) { + labels: labels, + datasets: timesArray.map(function(times, i) { return { - fillColor : 'rgba(255, 255, 255, 0)', - strokeColor : colors[i], - pointColor : colors[i], - pointStrokeColor : "#fff", - data : times + fillColor: 'rgba(255, 255, 255, 0)', + strokeColor: colors[i], + pointColor: colors[i], + pointStrokeColor: "#fff", + data: times }; }) }, { - bezierCurve : false + bezierCurve: false }); goButton.disabled = false; - goButton.innerHTML = 'Run Benchmarks'; + goButton.textContent = 'Run Benchmarks'; updateStatus(); } function updateStatus(density, testType, runCount) { if (!testType) { - statusSpan.innerHTML = ''; + statusSpan.textContent = ''; return; } - statusSpan.innerHTML = testType + ' ' + (100 * density) + + statusSpan.textContent = testType + ' ' + (100 * density) + '% binding density, ' + runCount + ' runs'; } diff --git a/src/template_element.js b/src/template_element.js index 30ac9fc..d0ad9c6 100644 --- a/src/template_element.js +++ b/src/template_element.js @@ -837,7 +837,7 @@ deepCloneIgnoreTemplateContent(content) : content.cloneNode(true); addMapBindings(instance, map, model, delegate, bound); - // TODO(rafaelw): We can do this more lazily, but setting a sentinal + // TODO(rafaelw): We can do this more lazily, but setting a sentinel // in the parent of the template element, and creating it when it's // asked for by walking back to find the iterating template. addTemplateInstanceRecord(instance, model); @@ -946,16 +946,13 @@ function newTokenCombinator(tokens) { return function(values) { - var newValue = ''; + var newValue = tokens[0]; - for (var i = 0, text = true; i < tokens.length; i++, text = !text) { - if (text) { - newValue += tokens[i]; - } else { - var value = values[i]; - if (value !== undefined) - newValue += value; - } + for (var i = 1; i < tokens.length; i += 2) { + var value = values[i]; + if (value !== undefined) + newValue += value; + newValue += tokens[i + 1]; } return newValue; diff --git a/third_party/ChangeSummary b/third_party/ChangeSummary index 2e61e7c..1b3771a 160000 --- a/third_party/ChangeSummary +++ b/third_party/ChangeSummary @@ -1 +1 @@ -Subproject commit 2e61e7c3b5579c3d4b0033289af6124f1297d49c +Subproject commit 1b3771a2fc4b98bf0060209ee38bf3bfd1a422be From 4a7088431903d710046299f1df39d3af73810b30 Mon Sep 17 00:00:00 2001 From: Rafael Weinstein Date: Thu, 11 Jul 2013 22:06:23 -0700 Subject: [PATCH 2/6] property delete node from templateIteratorTable R=arv BUG= Review URL: https://codereview.appspot.com/10963045 --- src/template_element.js | 2 +- third_party/ChangeSummary | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/template_element.js b/src/template_element.js index d0ad9c6..512bbe8 100644 --- a/src/template_element.js +++ b/src/template_element.js @@ -1274,7 +1274,7 @@ if (!this.inputs.size) { // End iteration - templateIteratorTable.delete(this); + templateIteratorTable.delete(this.templateElement_); this.close(); } }, diff --git a/third_party/ChangeSummary b/third_party/ChangeSummary index 1b3771a..011db43 160000 --- a/third_party/ChangeSummary +++ b/third_party/ChangeSummary @@ -1 +1 @@ -Subproject commit 1b3771a2fc4b98bf0060209ee38bf3bfd1a422be +Subproject commit 011db4367310242854631aa14caef7c68e406d83 From 6ca16d043ed4e62bdea3f63dc2692b5aec01a650 Mon Sep 17 00:00:00 2001 From: rafaelw Date: Thu, 11 Jul 2013 22:16:53 -0700 Subject: [PATCH 3/6] Update syntax_api.md --- docs/syntax_api.md | 61 +++++----------------------------------------- 1 file changed, 6 insertions(+), 55 deletions(-) diff --git a/docs/syntax_api.md b/docs/syntax_api.md index 9484d0c..9b8c207 100644 --- a/docs/syntax_api.md +++ b/docs/syntax_api.md @@ -20,18 +20,12 @@ MDV's native features enables a wide-range of use cases, but (by design) don't a * ... And anything else you'd like. -Enabling these features in MDV is a matter of implementing and registering a Custom Syntax. +Enabling these features in MDV is a matter of implementing and registering a binding delegate. ### Basic usage -```html - -``` - ```JavaScript -HTMLTemplateElement.syntax['MySyntax'] = { +templateElement.bindingDelegate = { getBinding: function(model, path, name, node) { // If this function is defined, the syntax can override // the default binding behavior @@ -44,52 +38,9 @@ HTMLTemplateElement.syntax['MySyntax'] = { } ``` -### Custom Syntax Registration - -A Custom Syntax is an object which contains one or more syntax methods which implement specialized behavior. This object is registered with MDV via the HTMLTemplateElement. The syntax need only implement syntax methods it requires to accomplish its goals. - -```JavaScript -var syntax = { - getBinding: function(model, path, name, node) {}, - getInstanceModel: function(template, model) {} -}; -HTMLTemplateElement.syntax['name'] = syntax; -``` - -### Custom Syntax Usage - -The `