Skip to content

Commit

Permalink
fixing more IE problems with matches selector, bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
BowlingX committed Mar 30, 2015
1 parent ae80f88 commit b4f115c
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 9 deletions.
11 changes: 9 additions & 2 deletions build/js/marklib.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build/js/marklib.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/js/marklib.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/js/marklib.min.map

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ <h2>A second paragraph with some latin like text</h2>
<button id="action-mark"><i class="fa fa-eraser"></i> Mark selection</button>
<button class="warn" id="action-clear"><i class="fa fa-trash-o"></i></button>
</div>
<p class="text-center subline tight">Marklib.Rendering depends on zero libraries and is just around 10kb minified</p>
<p class="text-center subline tight">Marklib depends on zero libraries and is just around 10kb minified</p>

</div>
</div>
Expand Down Expand Up @@ -129,6 +129,7 @@ <h2>A second paragraph with some latin like text</h2>
var selection = document.getSelection(), renderer = new Marklib.Rendering(document),
result = renderer.renderWithRange(selection.getRangeAt(0));
selection.removeAllRanges();
console.log(result);
savedRanges.push(result);
localStorage.setItem(STORAGE_KEY, JSON.stringify(savedRanges));
} catch (e) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "marklib",
"version": "0.3.0",
"version": "0.4.0",
"main": "build/js/marklib.js",
"repository": {
"type": "git",
Expand Down
3 changes: 2 additions & 1 deletion src/main/Rendering.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,8 @@ class Rendering {
if (Node.TEXT_NODE === currentNext.nodeType) {
wrapIf(currentNext);
} else {
if (currentNext.contains(endContainer)) {

if (!!(currentNext.compareDocumentPosition(endContainer) & 16)) {
this.walkDom(currentNext, (e) => {
if (e === endContainer) {
return false;
Expand Down
10 changes: 9 additions & 1 deletion src/main/util/Util.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global Node, NodeList */
/* global Node, NodeList, Element */

/**
* @type {string}
Expand All @@ -17,6 +17,14 @@ export const DATA_IS_SELECTION = 'data-is-selection';
*/
const SERIALIZE_SEPARATOR = ";";

// polyfill for matchesSelector, IE 10/11 does not support Element.matches
if (Element && !Element.prototype.matches) {
var p = Element.prototype;
p.matches = p.matchesSelector ||
p.mozMatchesSelector || p.msMatchesSelector ||
p.oMatchesSelector || p.webkitMatchesSelector;
}

/**
* Utility class
* Contains DOM/Node manipulation helpers
Expand Down

0 comments on commit b4f115c

Please sign in to comment.