Skip to content

Commit

Permalink
fix script in svg (close #2735) (#2736)
Browse files Browse the repository at this point in the history
  • Loading branch information
LavrovArtem committed Feb 8, 2022
1 parent b5c162c commit fd3fb15
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/client/dom-processor/client-dom-adapter.ts
Expand Up @@ -51,11 +51,11 @@ export default class ClientDomAdapter extends BaseDomAdapter {
}

setScriptContent (script: HTMLElement, content: string): void {
nativeMethods.scriptTextSetter.call(script, content);
nativeMethods.nodeTextContentSetter.call(script, content);
}

getScriptContent (script: HTMLElement) {
return nativeMethods.scriptTextGetter.call(script);
return nativeMethods.nodeTextContentGetter.call(script);
}

getStyleContent (style: HTMLElement) {
Expand Down
21 changes: 21 additions & 0 deletions test/client/fixtures/utils/dom-test.js
Expand Up @@ -1165,3 +1165,24 @@ test('hammerhead should use the native classList getter in addClass, removeClass

Object.defineProperty(window[elementClassListPropOwnerName], 'classList', storedСlassListDescriptor);
});

test('should not throw an error when process a script inside the svg (GH-2735)', function () {
var div = document.createElement('div');

document.body.appendChild(div);

div.innerHTML = [
'<?xml version="1.0" standalone="no"?>',
'<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" ',
' "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">',
'<svg xmlns="http://www.w3.org/2000/svg" width="6cm" height="5cm" viewBox="0 0 600 500" version="1.1">',
' <script type="application/ecmascript"> <![CDATA[',
' var some = 123;',
' ]]> <\/script>', // eslint-disable-line
'</svg>'
].join('\n');

ok(true);

document.body.removeChild(div);
});

0 comments on commit fd3fb15

Please sign in to comment.