move new hyperjson into common

This commit is contained in:
ansuz
2016-04-20 14:14:06 +02:00
parent 103bb69daa
commit 3598c93098
2 changed files with 2 additions and 141 deletions

View File

@@ -24,7 +24,8 @@ define([], function () {
return callOnHyperJSON(child, cb);
} else if (typeof (child) === 'string') {
// string nodes have leading and trailing quotes
return child.replace(/(^"|"$)/g,"");
// don't strip them!
return child; //child.replace(/(^"|"$)/g,"");
} else {
// the above branches should cover all methods
// if we hit this, there is a problem
@@ -95,21 +96,6 @@ define([], function () {
sel = sel +'#'+ attributes.id;
delete attributes.id;
}
if(attributes.class){
// actually parse out classes so that we produce a valid selector
// string. leading or trailing spaces would have caused it to choke
// these are really common in generated html
/* TODO this can be done with RegExps alone, and it will be faster
but this works and is a little less error prone, albeit slower
come back and speed it up when it comes time to optimize */
sel = sel + attributes.class
.split(/\s+/g)
.filter(isValidClass)
.map(classify)
.join('')
.replace(/\.\./g, '.');
delete attributes.class;
}
result.push(sel);
// second element of the array is the element attributes