-
Notifications
You must be signed in to change notification settings - Fork 47.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Workaround IE lacking innerHTML on SVG elements * Add tests for setInnerHTML * Correctly check if node has innerHTML property * Ensure tests for setInnerHTML actually tests both codepaths * Provide mock element for setInnerHTML tests * Only use SVG setInnerHTML workaround for SVG elements
- Loading branch information
1 parent
5331323
commit 99d8524
Showing
3 changed files
with
62 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/** | ||
* Copyright 2016-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
* | ||
* @emails react-core | ||
*/ | ||
|
||
'use strict'; | ||
|
||
var setInnerHTML = require('setInnerHTML'); | ||
var DOMNamespaces = require('DOMNamespaces'); | ||
|
||
describe('setInnerHTML', function() { | ||
describe('when the node has innerHTML property', () => { | ||
it('sets innerHTML on it', function() { | ||
var node = document.createElement('div'); | ||
var html = '<h1>hello</h1>'; | ||
setInnerHTML(node, html); | ||
expect(node.innerHTML).toBe(html); | ||
}); | ||
}); | ||
|
||
describe('when the node does not have an innerHTML property', () => { | ||
it('sets innerHTML on it', function() { | ||
// Create a mock node that looks like an SVG in IE (without innerHTML) | ||
var node = { | ||
namespaceURI: DOMNamespaces.svg, | ||
appendChild: jasmine.createSpy(), | ||
}; | ||
|
||
var html = '<circle></circle><rect></rect>'; | ||
setInnerHTML(node, html); | ||
|
||
expect(node.appendChild.calls.argsFor(0)[0].outerHTML).toBe('<circle></circle>'); | ||
expect(node.appendChild.calls.argsFor(1)[0].outerHTML).toBe('<rect></rect>'); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters