Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
81159 views
1
/**
2
* Copyright 2013-2014, Facebook, Inc.
3
* All rights reserved.
4
*
5
* This source code is licensed under the BSD-style license found in the
6
* LICENSE file in the root directory of this source tree. An additional grant
7
* of patent rights can be found in the PATENTS file in the same directory.
8
*
9
* @emails react-core
10
*/
11
12
/*jslint evil: true */
13
14
"use strict";
15
16
describe('ReactDOMIDOperations', function() {
17
var DOMPropertyOperations = require('DOMPropertyOperations');
18
var ReactDOMIDOperations = require('ReactDOMIDOperations');
19
var ReactMount = require('ReactMount');
20
var keyOf = require('keyOf');
21
22
it('should disallow updating special properties', function() {
23
spyOn(ReactMount, "getNode");
24
spyOn(DOMPropertyOperations, "setValueForProperty");
25
26
expect(function() {
27
ReactDOMIDOperations.updatePropertyByID(
28
'testID',
29
keyOf({dangerouslySetInnerHTML: null}),
30
{__html: 'testContent'}
31
);
32
}).toThrow();
33
34
expect(
35
ReactMount.getNode.argsForCall[0][0]
36
).toBe('testID');
37
38
expect(
39
DOMPropertyOperations.setValueForProperty.callCount
40
).toBe(0);
41
});
42
43
it('should update innerHTML and preserve whitespace', function() {
44
var stubNode = document.createElement('div');
45
spyOn(ReactMount, "getNode").andReturn(stubNode);
46
47
var html = '\n \t <span> \n testContent \t </span> \n \t';
48
49
ReactDOMIDOperations.updateInnerHTMLByID(
50
'testID',
51
html
52
);
53
54
expect(
55
ReactMount.getNode.argsForCall[0][0]
56
).toBe('testID');
57
58
expect(stubNode.innerHTML).toBe(html);
59
});
60
});
61
62