mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-02 02:02:43 +00:00
Simplify string splitting code
String.split will return the substring before > or the whole string if no > exists.
This commit is contained in:
@@ -787,8 +787,9 @@ const processStyleTags = (string)=>{
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//Given a string representing an HTML element, extract all of its properties (id, class, style, and other attributes)
|
||||||
const extractHTMLStyleTags = (htmlString)=>{
|
const extractHTMLStyleTags = (htmlString)=>{
|
||||||
const firstElementOnly = htmlString.indexOf('>') > 0 ? htmlString.substring(0, htmlString.indexOf('>')) : htmlString;
|
const firstElementOnly = htmlString.split('>')[0];
|
||||||
const id = firstElementOnly.match(/id="([^"]*)"/)?.[1] || null;
|
const id = firstElementOnly.match(/id="([^"]*)"/)?.[1] || null;
|
||||||
const classes = firstElementOnly.match(/class="([^"]*)"/)?.[1] || null;
|
const classes = firstElementOnly.match(/class="([^"]*)"/)?.[1] || null;
|
||||||
const styles = firstElementOnly.match(/style="([^"]*)"/)?.[1] || null;
|
const styles = firstElementOnly.match(/style="([^"]*)"/)?.[1] || null;
|
||||||
|
|||||||
Reference in New Issue
Block a user