<commit_before>import rgba from './rgba';
import {
    ART
} from 'react-native';

let {
    LinearGradient,
    RadialGradient
    } = ART;

let fillPatterns = {};
let fillReg = /^url\(#(\w+?)\)$/;

function isGradient(obj) {
    return obj instanceof LinearGradient || obj instanceof RadialGradient;
}

export default function (props) {
    let {fill} = props;

    if (fill) {
        if (isGradient(fill)) {
            return fill;
        }

        let fillOpacity = +props.fillOpacity;
        if (isNaN(fillOpacity)) {
            fillOpacity = 1;
        }

        // 尝试匹配 fill="url(#pattern)"
        let matched = fill.match(fillReg);
        if (matched) {
            let patternName = `${matched[1]}:${props.svgId}`;
            let pattern = fillPatterns[patternName];
            if (pattern) {
                if (pattern.length === 2) {
                    let dimensions = this.getBoundingBox();
                    return pattern(dimensions, fillOpacity);
                } else {
                    return pattern(fillOpacity);
                }
            }
            return null;
        }

        return rgba(props.fill, fillOpacity);
    } else if (props.fill === undefined) {
        return rgba('#000', fillOpacity);
    } else {
        return null;
    }

}

function set(id, pattern) {
    fillPatterns[id] = pattern;
}

function remove(id) {
    delete fillPatterns[id];
}

export {
    set,
    remove
}
<commit_msg>FIX: Check for fillOpacity when fill is undefined<commit_after>import rgba from './rgba';
import {
    ART
} from 'react-native';

let {
    LinearGradient,
    RadialGradient
    } = ART;

let fillPatterns = {};
let fillReg = /^url\(#(\w+?)\)$/;

function isGradient(obj) {
    return obj instanceof LinearGradient || obj instanceof RadialGradient;
}

export default function (props) {
    let {fill} = props;

    if (fill) {
        if (isGradient(fill)) {
            return fill;
        }

        let fillOpacity = +props.fillOpacity;
        if (isNaN(fillOpacity)) {
            fillOpacity = 1;
        }

        // 尝试匹配 fill="url(#pattern)"
        let matched = fill.match(fillReg);
        if (matched) {
            let patternName = `${matched[1]}:${props.svgId}`;
            let pattern = fillPatterns[patternName];
            if (pattern) {
                if (pattern.length === 2) {
                    let dimensions = this.getBoundingBox();
                    return pattern(dimensions, fillOpacity);
                } else {
                    return pattern(fillOpacity);
                }
            }
            return null;
        }

        return rgba(props.fill, fillOpacity);
    } else if (props.fill === undefined) {
        
        let fillOpacity = +props.fillOpacity;
        if (isNaN(fillOpacity)) {
            fillOpacity = 1;
        }
        return rgba('#000', fillOpacity);
    } else {
        return null;
    }

}

function set(id, pattern) {
    fillPatterns[id] = pattern;
}

function remove(id) {
    delete fillPatterns[id];
}

export {
    set,
    remove
}

{'fraction_non_alphanumeric': 0.12199089134677944, 'fraction_numerical': 0.004229017566688354, 'mean_word_length': 1.7777777777777777, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5477692', 'n_tokens_mistral': 961, 'n_tokens_neox': 905, 'n_words': 214}