MCPcopy Create free account
hub / github.com/textAngular/textAngular / wrapNested

Function wrapNested

src/factories.js:134–151  ·  view source on GitHub ↗
(html, wrapTag)

Source from the content-addressed store, hash-verified

132 var styleRegexString = '(' + styleMatch.join('|') + ')';
133
134 function wrapNested(html, wrapTag) {
135 var depth = 0;
136 var lastIndex = 0;
137 var match;
138 var tagRegex = /<[^>]*>/ig;
139 while(match = tagRegex.exec(html)){
140 lastIndex = match.index;
141 if(match[0].substr(1, 1) === '/'){
142 if(depth === 0) break;
143 else depth--;
144 }else depth++;
145 }
146 return wrapTag +
147 html.substring(0, lastIndex) +
148 // get the start tags reversed - this is safe as we construct the strings with no content except the tags
149 angular.element(wrapTag)[0].outerHTML.substring(wrapTag.length) +
150 html.substring(lastIndex);
151 }
152
153 function transformLegacyStyles(html){
154 if(!html || !angular.isString(html) || html.length <= 0) return html;

Callers 1

transformLegacyStylesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…