Skip to content

Commit

Permalink
use newer syntax for custom elements, if maybe supported? - #3335
Browse files Browse the repository at this point in the history
  • Loading branch information
evs-chris committed Mar 18, 2021
1 parent 6e9d117 commit 7f10049
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/utils/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,28 @@ import { isString, isNumber } from 'utils/is';

let createElement, matches, div, methodNames, unprefixed, prefixed, i, j, makeFunction;

const customStr = 'registerElement' in doc;
function wrap(is) {
return customStr ? is : { is };
}

// Test for SVG support
if (!svg) {
/* istanbul ignore next */
createElement = (type, ns, extend) => {
createElement = (type, ns, is) => {
if (ns && ns !== html) {
throw "This browser does not support namespaces other than http://www.w3.org/1999/xhtml. The most likely cause of this error is that you're trying to render SVG in an older browser. See http://ractive.js.org/support/#svgs for more information";
}

return extend ? doc.createElement(type, extend) : doc.createElement(type);
return is ? doc.createElement(type, wrap(is)) : doc.createElement(type);
};
} else {
createElement = (type, ns, extend) => {
createElement = (type, ns, is) => {
if (!ns || ns === html) {
return extend ? doc.createElement(type, extend) : doc.createElement(type);
return is ? doc.createElement(type, wrap(is)) : doc.createElement(type);
}

return extend ? doc.createElementNS(ns, type, extend) : doc.createElementNS(ns, type);
return is ? doc.createElementNS(ns, type, wrap(is)) : doc.createElementNS(ns, type);
};
}

Expand Down

0 comments on commit 7f10049

Please sign in to comment.