From a7e58993cd840e1b65bbd02727a4ab09a9fcca71 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Wed, 28 Aug 2013 10:49:45 +0200 Subject: [ADD] oe_dirty handling via mutation observers shim necessary for browsers supporting old mutation events but not new mutation observers bzr revid: xmo@openerp.com-20130828084945-yfqrs0v9v8iecwjm --- .../static/lib/MutationObservers/test/callback.js | 72 ++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 addons/website/static/lib/MutationObservers/test/callback.js (limited to 'addons/website/static/lib/MutationObservers/test/callback.js') diff --git a/addons/website/static/lib/MutationObservers/test/callback.js b/addons/website/static/lib/MutationObservers/test/callback.js new file mode 100644 index 00000000000..b3083c7bec3 --- /dev/null +++ b/addons/website/static/lib/MutationObservers/test/callback.js @@ -0,0 +1,72 @@ +/* + * Copyright 2012 The Polymer Authors. All rights reserved. + * Use of this source code is governed by a BSD-style + * license that can be found in the LICENSE file. + */ + +suite('JsMutationObserver callback', function() { + + test('One observer, two attribute changes', function(cont) { + var div = document.createElement('div'); + var observer = new JsMutationObserver(function(records) { + assert.strictEqual(records.length, 2); + + expectRecord(records[0], { + type: 'attributes', + target: div, + attributeName: 'a', + attributeNamespace: null + }); + expectRecord(records[1], { + type: 'attributes', + target: div, + attributeName: 'a', + attributeNamespace: null + }); + + cont(); + }); + + observer.observe(div, { + attributes: true + }); + + div.setAttribute('a', 'A'); + div.setAttribute('a', 'B'); + }); + + test('nested changes', function(cont) { + var div = document.createElement('div'); + var i = 0; + var observer = new JsMutationObserver(function(records) { + assert.strictEqual(records.length, 1); + + if (i === 0) { + expectRecord(records[0], { + type: 'attributes', + target: div, + attributeName: 'a', + attributeNamespace: null + }); + div.setAttribute('b', 'B'); + i++; + } else { + expectRecord(records[0], { + type: 'attributes', + target: div, + attributeName: 'b', + attributeNamespace: null + }); + + cont(); + } + }); + + observer.observe(div, { + attributes: true + }); + + div.setAttribute('a', 'A'); + }); + +}); \ No newline at end of file -- cgit v1.2.3