From 57cb3435c64b560f9db8af3396eaa929d55285b9 Mon Sep 17 00:00:00 2001 From: Erik Arvidsson Date: Wed, 13 Nov 2013 17:06:51 -0500 Subject: [PATCH] Fix issue with WebIDL attributes on Range --- shadowdom.js | 2 +- src/wrappers/Range.js | 2 +- test/js/Range.js | 22 ++++++++++++++++++++++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/shadowdom.js b/shadowdom.js index 3808328..e07d7b8 100644 --- a/shadowdom.js +++ b/shadowdom.js @@ -39,13 +39,13 @@ 'src/wrappers/HTMLUnknownElement.js', 'src/wrappers/CanvasRenderingContext2D.js', 'src/wrappers/WebGLRenderingContext.js', + 'src/wrappers/Range.js', 'src/wrappers/generic.js', 'src/wrappers/ShadowRoot.js', 'src/ShadowRenderer.js', 'src/wrappers/elements-with-form-property.js', 'src/wrappers/Document.js', 'src/wrappers/Window.js', - 'src/wrappers/Range.js', 'src/wrappers/override-constructors.js' ].forEach(function(src) { document.write(''); diff --git a/src/wrappers/Range.js b/src/wrappers/Range.js index 6de7971..bcf1de3 100644 --- a/src/wrappers/Range.js +++ b/src/wrappers/Range.js @@ -85,7 +85,7 @@ }; } - registerWrapper(window.Range, Range); + registerWrapper(window.Range, Range, document.createRange()); scope.wrappers.Range = Range; diff --git a/test/js/Range.js b/test/js/Range.js index 7a2a301..23d0b49 100644 --- a/test/js/Range.js +++ b/test/js/Range.js @@ -33,4 +33,26 @@ suite('Range', function() { assert.equal(fragment.childNodes.length, 1); }); + test('WebIDL attributes', function() { + var range = document.createRange(); + + assert.isTrue('collapsed' in range); + assert.isFalse(range.hasOwnProperty('collapsed')); + + assert.isTrue('commonAncestorContainer' in range); + assert.isFalse(range.hasOwnProperty('commonAncestorContainer')); + + assert.isTrue('endContainer' in range); + assert.isFalse(range.hasOwnProperty('endContainer')); + + assert.isTrue('endOffset' in range); + assert.isFalse(range.hasOwnProperty('endOffset')); + + assert.isTrue('startContainer' in range); + assert.isFalse(range.hasOwnProperty('startContainer')); + + assert.isTrue('startOffset' in range); + assert.isFalse(range.hasOwnProperty('startOffset')); + }); + });