Skip to content

Commit

Permalink
Normalize replacement character away as well
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon committed Oct 5, 2017
1 parent b4e8eb9 commit c2f4d32
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/renderers/dom/fiber/ReactDOMFiberComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,20 @@ if (__DEV__) {
};

// HTML parsing normalizes CR and CRLF to LF.
// It also can turn \u0000 into \uFFFD inside attributes.
// https://www.w3.org/TR/html5/single-page.html#preprocessing-the-input-stream
// If we have a mismatch, it might be caused by that.
// We won't be patching up in this case as that matches our past behavior.
var NORMALIZE_NEWLINES_REGEX = /\r\n?/g;
var NORMALIZE_NULL_REGEX = /\u0000/g;
var NORMALIZE_NULL_AND_REPLACEMENT_REGEX = /\u0000|\uFFFD/g;

var normalizeMarkupForTextOrAttribute = function(markup: mixed): string {
const markupString = typeof markup === 'string'
? markup
: '' + (markup: any);
return markupString
.replace(NORMALIZE_NEWLINES_REGEX, '\n')
.replace(NORMALIZE_NULL_REGEX, '');
.replace(NORMALIZE_NULL_AND_REPLACEMENT_REGEX, '');
};

var warnForTextDifference = function(
Expand Down

0 comments on commit c2f4d32

Please sign in to comment.