Skip to content

Incorrect Handling of Style Elements in addStyleSheet Function #257

@Imran-imtiaz48

Description

@Imran-imtiaz48

The addStyleSheet function creates a

element, sets its innerHTML to include a <style> tag, then attempts to insert the style element into the using p.lastChild. This approach can break in older IE versions (especially IE7 and below), where parsing of <style> inside another tag like

may not behave reliably.


var p = ownerDocument.createElement('p'),
    parent = ownerDocument.getElementsByTagName('head')[0] || ownerDocument.documentElement;

p.innerHTML = 'x<style>' + cssText + '</style>';
return parent.insertBefore(p.lastChild, parent.firstChild);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions