MCPcopy Create free account
hub / github.com/UI5/webcomponents / extractAttributesFromString

Function extractAttributesFromString

packages/main/test/pages/diffable-html.js:2131–2155  ·  view source on GitHub ↗
(content)

Source from the content-addressed store, hash-verified

2129 };
2130
2131 var extractAttributesFromString = function (content) {
2132 var attributes = {};
2133
2134 var pieces = content.split(/\s/);
2135 // Remove tag name.
2136 delete pieces[0];
2137
2138 pieces.forEach(function (element) {
2139 if (element.length === 0) {
2140 return;
2141 }
2142 if (element.indexOf('=') === -1) {
2143 attributes[element] = '';
2144 }
2145 });
2146
2147 var attributesRegex = /(\S+)=["']?((?:.(?!["']?\s+(?:\S+)=|[>"']))+.)["']?/gim;
2148
2149 var result;
2150 while ((result = attributesRegex.exec(content))) {
2151 attributes[result[1]] = result[2];
2152 }
2153
2154 return attributes;
2155 };
2156
2157 var parser = new htmlparser2.Parser(
2158 {

Callers 1

formatFunction · 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…