muu

DEPRECATED lightweight JS framework
git clone https://git.ce9e.org/muu.git

commit
bb10bf253cbc5b53f864315dd8f0678184230bb1
parent
247d93b425e128280b2139c927220debc5f3389b
Author
Tobias Bengfort <tobias.bengfort@gmx.net>
Date
2015-08-23 06:52
Merge branch 'fix-ie-8'

Diffstat

M bower.json 3 ++-
M src/muu-update-dom.js 9 ++++++---
M src/muu.js 4 +++-
M test/index.html 2 ++
M test/test-directive.js 6 +++---
M test/test-registry.js 3 ++-
M test/test-update-dom.js 2 +-

7 files changed, 19 insertions, 10 deletions


diff --git a/bower.json b/bower.json

@@ -25,6 +25,7 @@
   25    25     "blanket": "~1.1.7",
   26    26     "expect.js": "~0.3.1",
   27    27     "mocha": "~2.2.5",
   28    -1     "sinon-js": "~1.15.4"
   -1    28     "sinon-js": "~1.15.4",
   -1    29     "html5shiv": "~3.7.3"
   29    30   }
   30    31 }

diff --git a/src/muu-update-dom.js b/src/muu-update-dom.js

@@ -33,12 +33,15 @@ define(['muu-js-helpers'], function(_) {
   33    33         });
   34    34 
   35    35         _.forEach(targetAttrNames, function(name) {
   36    -1             if (!source.hasAttribute(name)) {
   -1    36             // NOTE: ie8.js creates some attribute
   -1    37             if (!source.hasAttribute(name) && name.substr(0, 7) !== '__IE8__') {
   37    38                 target.removeAttribute(name);
   38    39             }
   39    40         });
   40    41         _.forEach(sourceAttrNames, function(name) {
   41    -1             target.setAttribute(name, source.getAttribute(name));
   -1    42             if (target.getAttribute(name) !== source.getAttribute(name)) {
   -1    43                 target.setAttribute(name, source.getAttribute(name));
   -1    44             }
   42    45         });
   43    46     };
   44    47 
@@ -46,7 +49,7 @@ define(['muu-js-helpers'], function(_) {
   46    49         var nt = target.childNodes.length;
   47    50         var ns = source.childNodes.length;
   48    51 
   49    -1         if (target.nodeType === source.nodeType && target.nodeName === source.nodeName) {
   -1    52         if (target.nodeType === source.nodeType && target.nodeName === source.nodeName && target.type === source.type) {
   50    53             if (target.nodeType === 1) {
   51    54                 var muuClasses = _.filter(target.classList, function(cls) {
   52    55                     return cls.lastIndexOf('muu-', 0) === 0;

diff --git a/src/muu.js b/src/muu.js

@@ -120,7 +120,9 @@ define(['muu-template', 'muu-directive', 'muu-js-helpers', 'muu-dom-helpers'], f
  120   120          */
  121   121         this.linkAll = function(root) {
  122   122             // NOTE: root may be a DOM Node or a directive
  123    -1             var elements = root.querySelectorAll('muu:not(.muu-initialised)');
   -1   123             var elements = _.filter(root.querySelectorAll('muu'), function(element) {
   -1   124                 return !element.classList.contains('muu-initialised');
   -1   125             });
  124   126             return _.map(elements, function(element) {
  125   127                 return self.link(element);
  126   128             });

diff --git a/test/index.html b/test/index.html

@@ -9,6 +9,8 @@
    9     9     <!--[if IE 8]>
   10    10     <script src="../lib/ie8/build/ie8.js"></script>
   11    11     <script src="../lib/es5-shim/es5-shim.js"></script>
   -1    12     <script src="../lib/html5shiv/dist/html5shiv.js"></script>
   -1    13     <script>html5.addElements('muu');</script>
   12    14     <![endif]-->
   13    15     <!--[if lte IE 9]>
   14    16     <script src="../lib/dom4/build/dom4.js"></script>

diff --git a/test/test-directive.js b/test/test-directive.js

@@ -37,7 +37,7 @@ define(['muu-directive', 'muu-js-helpers', 'muu-dom-helpers'], function(Directiv
   37    37 
   38    38                 var button = element.querySelector('.button');
   39    39                 var spy = sinon.spy();
   40    -1                 element.addEventListener('muu-test', spy);
   -1    40                 element.addEventListener('muu-test', spy, false);
   41    41 
   42    42                 expect(spy.callCount).to.equal(0);
   43    43                 button.dispatchEvent($.createEvent('click'));
@@ -57,13 +57,13 @@ define(['muu-directive', 'muu-js-helpers', 'muu-dom-helpers'], function(Directiv
   57    57             });
   58    58             it('triggers the "muu-parent-update" event on child directives', function() {
   59    59                 var element = document.createElement('div');
   60    -1                 var template = '<muu class="muu-initialised">';
   -1    60                 var template = '<muu class="muu-initialised"></muu>';
   61    61                 var directive = new Directive(element, template, registry);
   62    62                 directive.update({});
   63    63 
   64    64                 var subdirective = element.querySelector('muu');
   65    65                 var spy = sinon.spy();
   66    -1                 subdirective.addEventListener('muu-parent-update', spy);
   -1    66                 subdirective.addEventListener('muu-parent-update', spy, false);
   67    67 
   68    68                 expect(spy.callCount).to.equal(0);
   69    69                 directive.update({});

diff --git a/test/test-registry.js b/test/test-registry.js

@@ -54,7 +54,8 @@ define(['muu', 'muu-directive', 'muu-js-helpers'], function(Registry, Directive,
   54    54                 expect(Directive.prototype.isPrototypeOf(directive)).to.be(true);
   55    55             });
   56    56             it('uses the registered template', function() {
   57    -1                 sinon.spy(registry, 'renderer');
   -1    57                 var originalRenderer = registry.renderer;
   -1    58                 registry.renderer = sinon.spy(originalRenderer);
   58    59 
   59    60                 var directive = registry.link(element, 'test');
   60    61                 directive.update();

diff --git a/test/test-update-dom.js b/test/test-update-dom.js

@@ -82,7 +82,7 @@ define(['muu-update-dom'], function(updateDOM) {
   82    82             target.innerHTML = '<input>';
   83    83             target.querySelector('input').value = '1';
   84    84             updateDOM(target, source);
   85    -1             expect(n(target.innerHTML)).to.equal('<input class="test">');
   -1    85             expect(n(target.innerHTML)).to.contain('class="test"');
   86    86             expect(target.querySelector('input').value).to.equal('1');
   87    87         });
   88    88         it('preserves input checked on checkbox', function() {