Skip to content

Commit

Permalink
Update lib files
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim committed Feb 12, 2015
1 parent f20f4a8 commit 4dae779
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 19 deletions.
29 changes: 21 additions & 8 deletions lib/rangy-classapplier.js
Expand Up @@ -9,8 +9,8 @@
*
* Copyright 2015, Tim Down
* Licensed under the MIT license.
* Version: 1.3.0-alpha.20150122
* Build date: 10 February 2015
* Version: 1.3.0-beta.1
* Build date: 12 February 2015
*/
(function(factory, root) {
if (typeof define == "function" && define.amd) {
Expand Down Expand Up @@ -102,6 +102,16 @@
return getSortedClassName(el1) == getSortedClassName(el2);
}

function hasAllClasses(el, className) {
var classes = className.split(/\s+/);
for (var i = 0, len = classes.length; i < len; ++i) {
if (!hasClass(el, trim(classes[i]))) {
return false;
}
}
return true;
}

function movePosition(position, oldParent, oldIndex, newParent, newIndex) {
var posNode = position.node, posOffset = position.offset;
var newNode = posNode, newOffset = posOffset;
Expand Down Expand Up @@ -412,7 +422,7 @@
var getPreviousMergeableTextNode = createAdjacentMergeableTextNodeGetter(false),
getNextMergeableTextNode = createAdjacentMergeableTextNodeGetter(true);


function Merge(firstNode) {
this.isElementMerge = (firstNode.nodeType == 1);
this.textNodes = [];
Expand Down Expand Up @@ -614,7 +624,7 @@

copyAttributesToElement: function(attrs, el) {
for (var attrName in attrs) {
if (attrs.hasOwnProperty(attrName)) {
if (attrs.hasOwnProperty(attrName) && !/^class(?:Name)?$/i.test(attrName)) {
el.setAttribute(attrName, attrs[attrName]);
}
}
Expand Down Expand Up @@ -726,7 +736,11 @@
var applier = this;
return each(props, function(p, propValue) {
if (p == "className") {
return sortClassName(el.className) == applier.elementSortedClassName;
// For checking whether we should reuse an existing element, we just want to check that the element
// has all the classes specified in the className property. When deciding whether the element is
// removable when unapplying a class, there is separate special handling to check whether the
// element has extra classes so the same simple check will do.
return hasAllClasses(el, propValue);
} else if (typeof propValue == "object") {
if (!applier.elementHasProperties(el[p], propValue)) {
return false;
Expand Down Expand Up @@ -933,8 +947,6 @@
// Remove class from any appropriate empty elements
var emptyElements = applier.getEmptyElements(range);

console.log(emptyElements);

forEach(emptyElements, function(el) {
removeClass(el, applier.className);
});
Expand Down Expand Up @@ -1032,6 +1044,7 @@
addClass: addClass,
removeClass: removeClass,
hasSameClasses: haveSameClasses,
hasAllClasses: hasAllClasses,
replaceWithOwnChildren: replaceWithOwnChildrenPreservingPositions,
elementsHaveSameNonClassAttributes: elementsHaveSameNonClassAttributes,
elementHasNonClassAttributes: elementHasNonClassAttributes,
Expand All @@ -1044,6 +1057,6 @@
api.CssClassApplier = api.ClassApplier = ClassApplier;
api.createCssClassApplier = api.createClassApplier = createClassApplier;
});

return rangy;
}, this);
6 changes: 3 additions & 3 deletions lib/rangy-core.js
Expand Up @@ -4,8 +4,8 @@
*
* Copyright 2015, Tim Down
* Licensed under the MIT license.
* Version: 1.3.0-alpha.20150122
* Build date: 10 February 2015
* Version: 1.3.0-beta.1
* Build date: 12 February 2015
*/

(function(factory, root) {
Expand Down Expand Up @@ -109,7 +109,7 @@
};

var api = {
version: "1.3.0-alpha.20150122",
version: "1.3.0-beta.1",
initialized: false,
isBrowser: isBrowser,
supported: true,
Expand Down
4 changes: 2 additions & 2 deletions lib/rangy-highlighter.js
Expand Up @@ -6,8 +6,8 @@
*
* Copyright 2015, Tim Down
* Licensed under the MIT license.
* Version: 1.3.0-alpha.20150122
* Build date: 10 February 2015
* Version: 1.3.0-beta.1
* Build date: 12 February 2015
*/
(function(factory, root) {
if (typeof define == "function" && define.amd) {
Expand Down
4 changes: 2 additions & 2 deletions lib/rangy-selectionsaverestore.js
Expand Up @@ -9,8 +9,8 @@
*
* Copyright 2015, Tim Down
* Licensed under the MIT license.
* Version: 1.3.0-alpha.20150122
* Build date: 10 February 2015
* Version: 1.3.0-beta.1
* Build date: 12 February 2015
*/
(function(factory, root) {
if (typeof define == "function" && define.amd) {
Expand Down
4 changes: 2 additions & 2 deletions lib/rangy-serializer.js
Expand Up @@ -10,8 +10,8 @@
*
* Copyright 2015, Tim Down
* Licensed under the MIT license.
* Version: 1.3.0-alpha.20150122
* Build date: 10 February 2015
* Version: 1.3.0-beta.1
* Build date: 12 February 2015
*/
(function(factory, root) {
if (typeof define == "function" && define.amd) {
Expand Down
4 changes: 2 additions & 2 deletions lib/rangy-textrange.js
Expand Up @@ -26,8 +26,8 @@
*
* Copyright 2015, Tim Down
* Licensed under the MIT license.
* Version: 1.3.0-alpha.20150122
* Build date: 10 February 2015
* Version: 1.3.0-beta.1
* Build date: 12 February 2015
*/

/**
Expand Down

0 comments on commit 4dae779

Please sign in to comment.